Rust for Linux List
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: Tamir Duberstein <tamird@kernel.org>,
	Malte Wechter <maltewechter@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Jesung Yang" <y.j3ms.n@gmail.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust-analyzer: update generate_rust_analyzer to pass cfg to macros crate
Date: Sat, 09 May 2026 10:01:21 +0200	[thread overview]
Message-ID: <87cxz56mge.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <CAJ-ks9=Cr1Mn1EXsWqG+KE-Y2Ed0a21PMfERjNr+M1wdgNaqjw@mail.gmail.com>

Hi Tamir,

"Tamir Duberstein" <tamird@kernel.org> writes:

> On Fri, May 8, 2026 at 3:04 AM Malte Wechter <maltewechter@gmail.com> wrote:
>>
>> pass kernel configurations to the macros crate to prevent rust-analyzer
>> from marking conditionally included macros as 'never included'.
>> Add the generated configurations to the macros cfg list
>> so rust-analyzer correctly hints inclusion and exclusion.
>>
>> Signed-off-by: Malte Wechter <maltewechter@gmail.com>
>
> Hi Malte, thanks for your patch. I haven't seen this issue. Could you
> please help me reproduce what you're seeing?

We are moving some of the configfs macro logic to procedural
implementations, now that we have syn. We are going to gate the macro on
CONFIG_CONFIGFS_FS. Malte noticed that rust-analyzer does not understand
the gating in the macros crate. rust-analyzer does not know that
CONFIG_CONFIGFS_FS is set, so rust-analyzer does not function at all for
our module:

--- a/rust/macros/lib.rs
+++ b/rust/macros/lib.rs
@@ -15,6 +15,8 @@
 #![cfg_attr(not(CONFIG_RUSTC_HAS_SPAN_FILE), feature(proc_macro_span))]

 mod concat_idents;
+#[cfg(CONFIG_CONFIGFS_FS)]
+mod configfs_attrs;
 mod export;

> Directionally I think this patch is incorrect because the macros crate
> is a host-side crate and generated_cfg is for target-side cfgs.

We might want to differentiate macro implementations based on kernel
configuration, or as in our case, skip compilation of certain macros
when they are not used in the kernel build.


Best regards,
Andreas Hindborg



  reply	other threads:[~2026-05-09  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  7:04 [PATCH] rust-analyzer: update generate_rust_analyzer to pass cfg to macros crate Malte Wechter
2026-05-08 13:05 ` Tamir Duberstein
2026-05-09  8:01   ` Andreas Hindborg [this message]
2026-05-11  5:00     ` Andreas Hindborg
2026-05-11 14:40       ` Tamir Duberstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cxz56mge.fsf@t14s.mail-host-address-is-not-set \
    --to=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=maltewechter@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=y.j3ms.n@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox