[PATCH v2] scripts: generate_rust_analyzer: compile sysroot with correct edition

Tamir Duberstein posted 1 patch 3 weeks ago
scripts/generate_rust_analyzer.py | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
[PATCH v2] scripts: generate_rust_analyzer: compile sysroot with correct edition
Posted by Tamir Duberstein 3 weeks ago
Use `core_edition` for all sysroot crates rather than just core as all
were updated to edition 2024 in Rust 1.87.

Fixes: f4daa80d6be7 ("rust: compile libcore with edition 2024 for 1.87+")
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
Changes in v2:
- Revert rust/Makefile changes and add Miguel's analysis.
- Link to v1: https://patch.msgid.link/20260115-rust-analyzer-sysroot-v1-1-4de831df234a@gmail.com
---
 scripts/generate_rust_analyzer.py | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 6061bd6e2ebd..187243f7f7a8 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -61,7 +61,6 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
         display_name,
         deps,
         cfg=[],
-        edition="2021",
     ):
         append_crate(
             display_name,
@@ -69,13 +68,37 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
             deps,
             cfg,
             is_workspace_member=False,
-            edition=edition,
+            # Miguel Ojeda writes:
+            #
+            # > ... in principle even the sysroot crates may have different
+            # > editions.
+            #
+            # > For instance, in the move to 2024, it seems all happened at once
+            # > in 1.87.0 in these upstream commits:
+            #
+            # >     0e071c2c6a58 ("Migrate core to Rust 2024")
+            # >     f505d4e8e380 ("Migrate alloc to Rust 2024")
+            # >     0b2489c226c3 ("Migrate proc_macro to Rust 2024")
+            # >     993359e70112 ("Migrate std to Rust 2024")
+            #
+            # > But in the previous move to 2021, `std` moved in 1.59.0, while
+            # > the others in 1.60.0:
+            #
+            # >     b656384d8398 ("Update stdlib to the 2021 edition")
+            # >     06a1c14d52a8 ("Switch all libraries to the 2021 edition")
+            #
+            # Link: https://lore.kernel.org/all/CANiq72kd9bHdKaAm=8xCUhSHMy2csyVed69bOc4dXyFAW4sfuw@mail.gmail.com/
+            #
+            # At the time of writing all rust versions we support build the
+            # sysroot crates with the same edition. We may need to relax this
+            # assumption if future edition moves span multiple rust versions.
+            edition=core_edition,
         )
 
     # 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)`.
-    append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []), edition=core_edition)
+    append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []))
     append_sysroot_crate("alloc", ["core"])
     append_sysroot_crate("std", ["alloc", "core"])
     append_sysroot_crate("proc_macro", ["core", "std"])

---
base-commit: 74e15ac34b098934895fd27655d098971d2b43d9
change-id: 20260115-rust-analyzer-sysroot-5fb95aa985d2

Best regards,
--  
Tamir Duberstein <tamird@kernel.org>
Re: [PATCH v2] scripts: generate_rust_analyzer: compile sysroot with correct edition
Posted by Miguel Ojeda 2 weeks, 5 days ago
On Fri, Jan 16, 2026 at 9:46 PM Tamir Duberstein <tamird@kernel.org> wrote:
>
> Use `core_edition` for all sysroot crates rather than just core as all
> were updated to edition 2024 in Rust 1.87.
>
> Fixes: f4daa80d6be7 ("rust: compile libcore with edition 2024 for 1.87+")
> Signed-off-by: Tamir Duberstein <tamird@kernel.org>

Applied to `rust-fixes` -- thanks everyone!

I added Cc: stable as discussed in v1:

    Cc: stable@vger.kernel.org

    [ Added `>`s to make the quote a single block. - Miguel ]

Cheers,
Miguel
Re: [PATCH v2] scripts: generate_rust_analyzer: compile sysroot with correct edition
Posted by Tamir Duberstein 3 weeks ago
On Fri, Jan 16, 2026 at 3:46 PM Tamir Duberstein <tamird@kernel.org> wrote:
>
> Use `core_edition` for all sysroot crates rather than just core as all
> were updated to edition 2024 in Rust 1.87.
>
> Fixes: f4daa80d6be7 ("rust: compile libcore with edition 2024 for 1.87+")
> Signed-off-by: Tamir Duberstein <tamird@kernel.org>
> ---
> Changes in v2:
> - Revert rust/Makefile changes and add Miguel's analysis.
> - Link to v1: https://patch.msgid.link/20260115-rust-analyzer-sysroot-v1-1-4de831df234a@gmail.com
> ---
>  scripts/generate_rust_analyzer.py | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index 6061bd6e2ebd..187243f7f7a8 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -61,7 +61,6 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
>          display_name,
>          deps,
>          cfg=[],
> -        edition="2021",
>      ):
>          append_crate(
>              display_name,
> @@ -69,13 +68,37 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
>              deps,
>              cfg,
>              is_workspace_member=False,
> -            edition=edition,
> +            # Miguel Ojeda writes:
> +            #
> +            # > ... in principle even the sysroot crates may have different
> +            # > editions.
> +            #
> +            # > For instance, in the move to 2024, it seems all happened at once
> +            # > in 1.87.0 in these upstream commits:
> +            #
> +            # >     0e071c2c6a58 ("Migrate core to Rust 2024")
> +            # >     f505d4e8e380 ("Migrate alloc to Rust 2024")
> +            # >     0b2489c226c3 ("Migrate proc_macro to Rust 2024")
> +            # >     993359e70112 ("Migrate std to Rust 2024")
> +            #
> +            # > But in the previous move to 2021, `std` moved in 1.59.0, while
> +            # > the others in 1.60.0:
> +            #
> +            # >     b656384d8398 ("Update stdlib to the 2021 edition")
> +            # >     06a1c14d52a8 ("Switch all libraries to the 2021 edition")
> +            #
> +            # Link: https://lore.kernel.org/all/CANiq72kd9bHdKaAm=8xCUhSHMy2csyVed69bOc4dXyFAW4sfuw@mail.gmail.com/

Oops, the blank lines between paragraphs should probably begin with
`>` so that it is all one big block quote. Happy to send v3 or let
this happen on apply.

> +            #
> +            # At the time of writing all rust versions we support build the
> +            # sysroot crates with the same edition. We may need to relax this
> +            # assumption if future edition moves span multiple rust versions.
> +            edition=core_edition,
>          )
>
>      # 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)`.
> -    append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []), edition=core_edition)
> +    append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []))
>      append_sysroot_crate("alloc", ["core"])
>      append_sysroot_crate("std", ["alloc", "core"])
>      append_sysroot_crate("proc_macro", ["core", "std"])
>
> ---
> base-commit: 74e15ac34b098934895fd27655d098971d2b43d9
> change-id: 20260115-rust-analyzer-sysroot-5fb95aa985d2
>
> Best regards,
> --
> Tamir Duberstein <tamird@kernel.org>
>