* [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps
@ 2025-02-09 17:11 Tamir Duberstein
2025-02-09 17:34 ` Tamir Duberstein
2025-02-10 16:32 ` Fiona Behrens
0 siblings, 2 replies; 5+ messages in thread
From: Tamir Duberstein @ 2025-02-09 17:11 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Boris-Chengbiao Zhou, Fiona Behrens, Kees Cook
Cc: rust-for-linux, linux-kernel, Chayim Refael Friedman,
Tamir Duberstein
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`")
Suggested-by: Chayim Refael Friedman <chayimfr@gmail.com>
Signed-off-by: Tamir Duberstein <tamird@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 | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index aa8ea1a4dbe5..316174c22346 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -57,25 +57,33 @@ 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,
- )
-
append_crate(
"compiler_builtins",
srctree / "rust" / "compiler_builtins.rs",
[],
)
+ # NB: sysroot crates reexport items from one another so setting up our transitive dependencies
+ # here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth
+ # for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`.
+ for crate, deps in [
+ ("core", []),
+ ("alloc", ["compiler_builtins", "core"]),
+ ("std", ["alloc", "compiler_builtins", "core"]),
+ ("proc_macro", ["core", "std"]),
+ ]:
+ append_crate(
+ crate,
+ sysroot_src / crate / "src" / "lib.rs",
+ deps=deps,
+ cfg=crates_cfgs.get(crate, []),
+ is_workspace_member=False,
+ )
+
append_crate(
"macros",
srctree / "rust" / "macros" / "lib.rs",
- [],
+ ["std", "proc_macro"],
is_proc_macro=True,
)
---
base-commit: 6273a058383e05465083b535ed9469f2c8a48321
change-id: 20250209-rust-analyzer-macros-core-dep-0f57868dd19f
Best regards,
--
Tamir Duberstein <tamird@gmail.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps
2025-02-09 17:11 [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps Tamir Duberstein
@ 2025-02-09 17:34 ` Tamir Duberstein
2025-02-10 16:32 ` Fiona Behrens
1 sibling, 0 replies; 5+ messages in thread
From: Tamir Duberstein @ 2025-02-09 17:34 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Boris-Chengbiao Zhou, Fiona Behrens, Kees Cook,
Danilo Krummrich, Lukas Wirth
Cc: rust-for-linux, linux-kernel, Chayim Refael Friedman
On Sun, Feb 9, 2025 at 12:12 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> 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`")
> Suggested-by: Chayim Refael Friedman <chayimfr@gmail.com>
> Signed-off-by: Tamir Duberstein <tamird@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 | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index aa8ea1a4dbe5..316174c22346 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -57,25 +57,33 @@ 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,
> - )
> -
> append_crate(
> "compiler_builtins",
> srctree / "rust" / "compiler_builtins.rs",
> [],
> )
>
> + # NB: sysroot crates reexport items from one another so setting up our transitive dependencies
> + # here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth
> + # for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`.
> + for crate, deps in [
> + ("core", []),
> + ("alloc", ["compiler_builtins", "core"]),
> + ("std", ["alloc", "compiler_builtins", "core"]),
> + ("proc_macro", ["core", "std"]),
> + ]:
> + append_crate(
> + crate,
> + sysroot_src / crate / "src" / "lib.rs",
> + deps=deps,
> + cfg=crates_cfgs.get(crate, []),
> + is_workspace_member=False,
> + )
> +
> append_crate(
> "macros",
> srctree / "rust" / "macros" / "lib.rs",
> - [],
> + ["std", "proc_macro"],
> is_proc_macro=True,
> )
>
>
> ---
> base-commit: 6273a058383e05465083b535ed9469f2c8a48321
> change-id: 20250209-rust-analyzer-macros-core-dep-0f57868dd19f
>
> Best regards,
> --
> Tamir Duberstein <tamird@gmail.com>
>
Adding Danilo and Lukas, missed from v1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps
2025-02-09 17:11 [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps Tamir Duberstein
2025-02-09 17:34 ` Tamir Duberstein
@ 2025-02-10 16:32 ` Fiona Behrens
2025-02-10 16:51 ` Tamir Duberstein
1 sibling, 1 reply; 5+ messages in thread
From: Fiona Behrens @ 2025-02-10 16:32 UTC (permalink / raw)
To: Tamir Duberstein
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Boris-Chengbiao Zhou, Kees Cook, rust-for-linux,
linux-kernel, Chayim Refael Friedman
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`")
> Suggested-by: Chayim Refael Friedman <chayimfr@gmail.com>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Competing with https://lore.kernel.org/rust-for-linux/20241205115438.234221-1-me@kloenk.dev/
but I do like your aproach more.
Reviewed-by: Fiona Behrens <me@kloenk.dev>
> ---
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps
2025-02-10 16:32 ` Fiona Behrens
@ 2025-02-10 16:51 ` Tamir Duberstein
2025-02-10 17:00 ` Fiona Behrens
0 siblings, 1 reply; 5+ messages in thread
From: Tamir Duberstein @ 2025-02-10 16:51 UTC (permalink / raw)
To: Fiona Behrens
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Boris-Chengbiao Zhou, Kees Cook, rust-for-linux,
linux-kernel, Chayim Refael Friedman
On Mon, Feb 10, 2025 at 11:32 AM Fiona Behrens <me@kloenk.dev> wrote:
>
> Competing with https://lore.kernel.org/rust-for-linux/20241205115438.234221-1-me@kloenk.dev/
> but I do like your aproach more.
Missed this one go by. Sorry!
> Reviewed-by: Fiona Behrens <me@kloenk.dev>
Thanks for reviewing! I'm going to respin v3 that looks a little bit
more like https://lore.kernel.org/all/20250209-rust-analyzer-host-v1-3-a2286a2a2fa3@gmail.com/
which is the proper fix. If you're OK with it, I'll keep your tag.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps
2025-02-10 16:51 ` Tamir Duberstein
@ 2025-02-10 17:00 ` Fiona Behrens
0 siblings, 0 replies; 5+ messages in thread
From: Fiona Behrens @ 2025-02-10 17:00 UTC (permalink / raw)
To: Tamir Duberstein
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Boris-Chengbiao Zhou, Kees Cook, rust-for-linux,
linux-kernel, Chayim Refael Friedman
Tamir Duberstein <tamird@gmail.com> writes:
> On Mon, Feb 10, 2025 at 11:32 AM Fiona Behrens <me@kloenk.dev> wrote:
>>
>> Competing with https://lore.kernel.org/rust-for-linux/20241205115438.234221-1-me@kloenk.dev/
>> but I do like your aproach more.
>
> Missed this one go by. Sorry!
No worries at all, was mostly also to make sure that not both gets merged.
>
>> Reviewed-by: Fiona Behrens <me@kloenk.dev>
>
> Thanks for reviewing! I'm going to respin v3 that looks a little bit
> more like https://lore.kernel.org/all/20250209-rust-analyzer-host-v1-3-a2286a2a2fa3@gmail.com/
> which is the proper fix. If you're OK with it, I'll keep your tag.
Sure, feel also free to ping on zullip if anything specific before
sending. But your code already looks very good. Like it with the types
and such.
Thanks
Fiona
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-10 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-09 17:11 [PATCH v2] scripts: generate_rust_analyzer.py: add missing macros deps Tamir Duberstein
2025-02-09 17:34 ` Tamir Duberstein
2025-02-10 16:32 ` Fiona Behrens
2025-02-10 16:51 ` Tamir Duberstein
2025-02-10 17:00 ` Fiona Behrens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox