[PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`

Tamir Duberstein posted 1 patch 9 months ago
rust/pin-init/internal/src/lib.rs   | 1 -
rust/pin-init/internal/src/quote.rs | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
[PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Tamir Duberstein 9 months ago
Replace the `#[path]` attribute with a symlink to work around a
limitation in rust-analyzer that requires all modules to belong to the
same "source root". This allows code navigation from `pin_init_internal`
to `quote` to work properly.

Link: https://github.com/rust-lang/rust-analyzer/issues/3898
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/pin-init/internal/src/lib.rs   | 1 -
 rust/pin-init/internal/src/quote.rs | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs
index babe5e878550..fdd95afe3864 100644
--- a/rust/pin-init/internal/src/lib.rs
+++ b/rust/pin-init/internal/src/lib.rs
@@ -20,7 +20,6 @@
 use proc_macro::TokenStream;
 
 #[cfg(kernel)]
-#[path = "../../../macros/quote.rs"]
 #[macro_use]
 mod quote;
 #[cfg(not(kernel))]
diff --git a/rust/pin-init/internal/src/quote.rs b/rust/pin-init/internal/src/quote.rs
new file mode 120000
index 000000000000..27a213d1a6ba
--- /dev/null
+++ b/rust/pin-init/internal/src/quote.rs
@@ -0,0 +1 @@
+../../../macros/quote.rs
\ No newline at end of file

---
base-commit: ff7f9b199e3f4cc7d61df5a9a26a7cbb5c1492e6
change-id: 20250319-pin-init-internal-quote-b7e15e9e8233

Best regards,
-- 
Tamir Duberstein <tamird@gmail.com>
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Benno Lossin 9 months ago
On Thu Mar 20, 2025 at 2:35 AM CET, Tamir Duberstein wrote:
> Replace the `#[path]` attribute with a symlink to work around a
> limitation in rust-analyzer that requires all modules to belong to the
> same "source root". This allows code navigation from `pin_init_internal`
> to `quote` to work properly.
>
> Link: https://github.com/rust-lang/rust-analyzer/issues/3898
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
>  rust/pin-init/internal/src/lib.rs   | 1 -
>  rust/pin-init/internal/src/quote.rs | 1 +
>  2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs
> index babe5e878550..fdd95afe3864 100644
> --- a/rust/pin-init/internal/src/lib.rs
> +++ b/rust/pin-init/internal/src/lib.rs
> @@ -20,7 +20,6 @@
>  use proc_macro::TokenStream;
>  
>  #[cfg(kernel)]
> -#[path = "../../../macros/quote.rs"]
>  #[macro_use]
>  mod quote;
>  #[cfg(not(kernel))]
> diff --git a/rust/pin-init/internal/src/quote.rs b/rust/pin-init/internal/src/quote.rs
> new file mode 120000
> index 000000000000..27a213d1a6ba
> --- /dev/null
> +++ b/rust/pin-init/internal/src/quote.rs
> @@ -0,0 +1 @@
> +../../../macros/quote.rs
> \ No newline at end of file
>
> ---
> base-commit: ff7f9b199e3f4cc7d61df5a9a26a7cbb5c1492e6
> change-id: 20250319-pin-init-internal-quote-b7e15e9e8233
>
> Best regards,

I'd rather not have this change, since this will introduce a dangling
symlink upstream [1].

[1]: https://github.com/rust-for-Linux/pin-init

---
Cheers,
Benno
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Tamir Duberstein 9 months ago
On Thu, Mar 20, 2025 at 8:16 AM Benno Lossin <benno.lossin@proton.me> wrote:
>
> On Thu Mar 20, 2025 at 2:35 AM CET, Tamir Duberstein wrote:
> > Replace the `#[path]` attribute with a symlink to work around a
> > limitation in rust-analyzer that requires all modules to belong to the
> > same "source root". This allows code navigation from `pin_init_internal`
> > to `quote` to work properly.
> >
> > Link: https://github.com/rust-lang/rust-analyzer/issues/3898
> > Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> > ---
> >  rust/pin-init/internal/src/lib.rs   | 1 -
> >  rust/pin-init/internal/src/quote.rs | 1 +
> >  2 files changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs
> > index babe5e878550..fdd95afe3864 100644
> > --- a/rust/pin-init/internal/src/lib.rs
> > +++ b/rust/pin-init/internal/src/lib.rs
> > @@ -20,7 +20,6 @@
> >  use proc_macro::TokenStream;
> >
> >  #[cfg(kernel)]
> > -#[path = "../../../macros/quote.rs"]
> >  #[macro_use]
> >  mod quote;
> >  #[cfg(not(kernel))]
> > diff --git a/rust/pin-init/internal/src/quote.rs b/rust/pin-init/internal/src/quote.rs
> > new file mode 120000
> > index 000000000000..27a213d1a6ba
> > --- /dev/null
> > +++ b/rust/pin-init/internal/src/quote.rs
> > @@ -0,0 +1 @@
> > +../../../macros/quote.rs
> > \ No newline at end of file
> >
> > ---
> > base-commit: ff7f9b199e3f4cc7d61df5a9a26a7cbb5c1492e6
> > change-id: 20250319-pin-init-internal-quote-b7e15e9e8233
> >
> > Best regards,
>
> I'd rather not have this change, since this will introduce a dangling
> symlink upstream [1].
>
> [1]: https://github.com/rust-for-Linux/pin-init

I agree it's aesthetically displeasing. I'm not aware of any
alternative that fixes the development workflow of this crate in the
kernel.
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Benno Lossin 9 months ago
On Thu Mar 20, 2025 at 2:31 PM CET, Tamir Duberstein wrote:
> On Thu, Mar 20, 2025 at 8:16 AM Benno Lossin <benno.lossin@proton.me> wrote:
>> I'd rather not have this change, since this will introduce a dangling
>> symlink upstream [1].
>>
>> [1]: https://github.com/rust-for-Linux/pin-init
>
> I agree it's aesthetically displeasing. I'm not aware of any
> alternative that fixes the development workflow of this crate in the
> kernel.

I don't think it's too bad, and this code is going away soon-ish
anyways.

---
Cheers,
Benno
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Tamir Duberstein 9 months ago
On Thu, Mar 20, 2025 at 10:10 AM Benno Lossin <benno.lossin@proton.me> wrote:
>
> On Thu Mar 20, 2025 at 2:31 PM CET, Tamir Duberstein wrote:
> > On Thu, Mar 20, 2025 at 8:16 AM Benno Lossin <benno.lossin@proton.me> wrote:
> >> I'd rather not have this change, since this will introduce a dangling
> >> symlink upstream [1].
> >>
> >> [1]: https://github.com/rust-for-Linux/pin-init
> >
> > I agree it's aesthetically displeasing. I'm not aware of any
> > alternative that fixes the development workflow of this crate in the
> > kernel.
>
> I don't think it's too bad, and this code is going away soon-ish
> anyways.

What would Andreas say? :)

I don't think the going away soon argument is relevant in this case -
the same applies to the dangling symlink.
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Alice Ryhl 9 months ago
On Wed, Mar 19, 2025 at 09:35:40PM -0400, Tamir Duberstein wrote:
> Replace the `#[path]` attribute with a symlink to work around a
> limitation in rust-analyzer that requires all modules to belong to the
> same "source root". This allows code navigation from `pin_init_internal`
> to `quote` to work properly.
> 
> Link: https://github.com/rust-lang/rust-analyzer/issues/3898
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

Are we allowed to have symlinks?

Alice
Re: [PATCH] rust: pin_init_internal: fix rust-analyzer `mod quote`
Posted by Tamir Duberstein 9 months ago
On Thu, Mar 20, 2025 at 3:46 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> On Wed, Mar 19, 2025 at 09:35:40PM -0400, Tamir Duberstein wrote:
> > Replace the `#[path]` attribute with a symlink to work around a
> > limitation in rust-analyzer that requires all modules to belong to the
> > same "source root". This allows code navigation from `pin_init_internal`
> > to `quote` to work properly.
> >
> > Link: https://github.com/rust-lang/rust-analyzer/issues/3898
> > Signed-off-by: Tamir Duberstein <tamird@gmail.com>
>
> Are we allowed to have symlinks?

There are 77 symlinks in the kernel by my count. Perhaps most
interesting are these:

include/dt-bindings/clock/qcom,dispcc-sm8150.h
include/dt-bindings/clock/qcom,dispcc-sm8350.h
include/dt-bindings/clock/qcom,sm8650-dispcc.h
include/dt-bindings/input/linux-event-codes.h

I'm not sure if there are further criteria we need to satisfy.