mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Tamir Duberstein" <tamird@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Boris-Chengbiao Zhou" <bobo1239@web.de>,
	"Fiona Behrens" <me@kloenk.dev>, "Kees Cook" <kees@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Chayim Refael Friedman" <chayimfr@gmail.com>
Subject: Re: [PATCH v3] scripts: generate_rust_analyzer.py: add missing macros deps
Date: Fri, 07 Mar 2025 11:56:45 +0100	[thread overview]
Message-ID: <874j055csy.fsf@kernel.org> (raw)
In-Reply-To: <20250210-rust-analyzer-macros-core-dep-v3-1-45eb4836f218@gmail.com> (Tamir Duberstein's message of "Mon, 10 Feb 2025 12:03:24 -0500")

"Tamir Duberstein" <tamird@gmail.com> writes:

> The macros crate has depended on std and proc_macro since its
> introduction in commit 1fbde52bde73 ("rust: add `macros` crate"). These
> dependencies were omitted from commit 8c4555ccc55c ("scripts: add
> `generate_rust_analyzer.py`") resulting in missing go-to-definition and
> autocomplete, and false-positive warnings emitted from rust-analyzer
> such as:
>
>   [{
>   	"resource": "/Users/tamird/src/linux/rust/macros/module.rs",
>   	"owner": "_generated_diagnostic_collection_name_#1",
>   	"code": {
>   		"value": "non_snake_case",
>   		"target": {
>   			"$mid": 1,
>   			"path": "/rustc/",
>   			"scheme": "https",
>   			"authority": "doc.rust-lang.org",
>   			"query": "search=non_snake_case"
>   		}
>   	},
>   	"severity": 4,
>   	"message": "Variable `None` should have snake_case name, e.g. `none`",
>   	"source": "rust-analyzer",
>   	"startLineNumber": 123,
>   	"startColumn": 17,
>   	"endLineNumber": 123,
>   	"endColumn": 21
>   }]
>
> Add the missing dependencies to improve the developer experience.
>
> Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`")
> Reviewed-by: Fiona Behrens <me@kloenk.dev>
> Suggested-by: Chayim Refael Friedman <chayimfr@gmail.com>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> Changes in v3:
> - Avoid shuffling compilter_builtins; it is not needed for RA support.
> - Align more closely with the long-term solution:
>   https://lore.kernel.org/all/20250209-rust-analyzer-host-v1-0-a2286a2a2fa3@gmail.com/.
> - Link to v2: https://lore.kernel.org/r/20250209-rust-analyzer-macros-core-dep-v2-1-897338344d16@gmail.com
>
> Changes in v2:
> - Change macros deps from [core] to [std, proc_macro], improving
>   autocomplete and go-to-definition.
> - Remove Wedson Almeida Filho <wedsonaf@google.com> from cc; email
>   bounced.
> - Link to v1: https://lore.kernel.org/r/20250209-rust-analyzer-macros-core-dep-v1-1-5ebeb3eb60a9@gmail.com
> ---
>  scripts/generate_rust_analyzer.py | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index aa8ea1a4dbe5..1394baa5ee9e 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -57,14 +57,26 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs):
>          crates_indexes[display_name] = len(crates)
>          crates.append(crate)
>
> -    # First, the ones in `rust/` since they are a bit special.
> -    append_crate(
> -        "core",
> -        sysroot_src / "core" / "src" / "lib.rs",
> -        [],
> -        cfg=crates_cfgs.get("core", []),
> -        is_workspace_member=False,
> -    )
> +    def append_sysroot_crate(
> +        display_name,
> +        deps,
> +        cfg=[],
> +    ):
> +        return append_crate(

Why the `return` here?

Otherwise looks good to me.

I never had any errors as described above, but I can confirm that go to
definition in `macros` for items in `proc_macro` work with this patch
applied. It does not work prior to applying the patch.


Tested-by: Andreas Hindborg <a.hindborg@kernel.org>


Best regards,
Andreas Hindborg



  parent reply	other threads:[~2025-03-07 10:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6-mv8ahCblqal1f_T1RcVPPPb6QEedsAXlhmcyCNC-lnvAj1USOInn0YNogItuEdy_KthnPdFDElN1F6A9ncwA==@protonmail.internalid>
2025-02-10 17:03 ` Tamir Duberstein
2025-03-05 23:14   ` Miguel Ojeda
2025-03-05 23:58     ` Tamir Duberstein
2025-03-07 10:56   ` Andreas Hindborg [this message]
2025-03-07 11:05     ` Tamir Duberstein
2025-03-07 11:48       ` Miguel Ojeda
2025-03-07 14:37         ` Tamir Duberstein
2025-03-10 21:45           ` Tamir Duberstein
2025-03-11 22:46   ` Miguel Ojeda

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=874j055csy.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=bobo1239@web.de \
    --cc=boqun.feng@gmail.com \
    --cc=chayimfr@gmail.com \
    --cc=gary@garyguo.net \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kloenk.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --cc=tmgross@umich.edu \
    /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

all inboxes | Powered by JetHome®