rust: compile libcore with edition 2024 for 1.87+
Subsystems (2)
Gary Guo
reviewerPATCH 1/1 rust: compile libcore with edition 2024 for 1.87+
Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage.
--- rust/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
rust/Makefile +9 -3
@@ -60,6 +60,12 @@ endif core-cfgs = \ --cfg no_fp_fmt_parse +ifeq ($(call rustc-min-version,108700),y) +core-cfgs += --edition=2024 +else +core-cfgs += --edition=2021 +endif + # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
@@ -106,7 +112,7 @@ rustdoc-macros: $(src)/macros/lib.rs FORCE # Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should # not be needed -- see https://github.com/rust-lang/rust/pull/128307. -rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks +rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks --edition=2021 rustdoc-core: private rustc_target_flags = $(core-cfgs) rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE +$(call if_changed,rustdoc)
@@ -416,7 +422,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L cmd_rustc_library = \ OBJTREE=$(abspath $(objtree)) \ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \ - $(filter-out $(skip_flags),$(rust_flags) $(rustc_target_flags)) \ + $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \ --emit=dep-info=$(depfile) --emit=obj=$@ \ --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ --crate-type rlib -L$(objtree)/$(obj) \
@@ -483,7 +489,7 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE $(obj)/exports.o: private skip_gendwarfksyms = 1 $(obj)/core.o: private skip_clippy = 1 -$(obj)/core.o: private skip_flags = -Wunreachable_pub +$(obj)/core.o: private skip_flags = -Wunreachable_pub --edition=2021 $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) $(obj)/core.o: private rustc_target_flags = $(core-cfgs) $(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
base-commit: 172a9d94339cea832d89630b89d314e41d622bd8
Signature · 1 line
2.47.2
Quoted 9 lines · Gary Guo
Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage.
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Signed-off-by Gary Guo <[email protected]>
Cc'ing est31 -- I will add:
Thanks!
Cheers,
Miguel
Quoted 8 lines · Gary Guo
Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage.
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Signed-off-by Gary Guo <[email protected]>
Miguel Ojeda
AppliedQuoted 9 lines · Gary Guo
Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage.
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Signed-off-by Gary Guo <[email protected]>
Applied to rust-next -- thanks everyone!
(I actually applied a couple days ago in advance of Monday's -next, which explains the following report)
[ J3m3 reported in Zulip [2] that the rust-analyzer target was
broken after this patch -- indeed, we need to avoid core-cfgs since those are passed to the rust-analyzer target.
So, instead, I tweaked the patch to create a new core-edition variable and explicitly mention the --edition flag instead of reusing core-cfgs.
In addition, pass a new argument using this new variable to generate_rust_analyzer.py so that we set the right edition there.
By the way, for future reference: the filter-out change is needed for Rust < 1.87, since otherwise we would skip the --edition=2021 we just added, ending up with no edition flag, and thus the compiler would default to the 2015 one.
[2] https://rust-for-linux.zulipchat.com/#narrow/channel/291565/topic/x/near/520206547
- Miguel ]
I also added:
since est31 told Gary in RustWeek, and we discussed the patch there.
@Gary: I hope the changes are OK with you (I can put the generate_rust_analyzer ones in a different commit if you prefer). Thanks!
Cheers,
Miguel
Quoted 41 lines · Miguel Ojeda
Quoted 9 lines · Gary Guo
Rust 1.87 (released on 2025-05-15) compiles core library with edition 2024 instead of 2021 [1]. Ensure that the edition matches libcore's expectation to avoid potential breakage.
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Signed-off-by Gary Guo <[email protected]>Applied to
rust-next-- thanks everyone!(I actually applied a couple days ago in advance of Monday's -next, which explains the following report)
[ J3m3 reported in Zulip [2] that the
rust-analyzertarget was
broken after this patch -- indeed, we need to avoidcore-cfgssince those are passed to therust-analyzertarget.So, instead, I tweaked the patch to create a new
core-editionvariable and explicitly mention the--editionflag instead of reusingcore-cfgs.In addition, pass a new argument using this new variable to
generate_rust_analyzer.pyso that we set the right edition there.By the way, for future reference: the
filter-outchange is needed for Rust < 1.87, since otherwise we would skip the--edition=2021we just added, ending up with no edition flag, and thus the compiler would default to the 2015 one.[2] https://rust-for-linux.zulipchat.com/#narrow/channel/291565/topic/x/near/520206547
- Miguel ]
I also added:
Reported-by est31 <[email protected]>
Quoted 9 lines
since est31 told Gary in RustWeek, and we discussed the patch there.
@Gary: I hope the changes are OK with you (I can put the
generate_rust_analyzerones in a different commit if you prefer). Thanks!Cheers,
Miguel
Hey Miguel, regarding the rust-analyzer changes:
I see only core was changed to use core_edition, but other sysroot crates (alloc, std, and proc_macro) still compile with edition 2021 despite all having been updated in the same upstream PR. Was this intentional, or just an omission?
Quoted 7 lines · Tamir Duberstein
Hey Miguel, regarding the rust-analyzer changes:
I see only core was changed to use
core_edition, but other sysroot crates (alloc, std, andproc_macro) still compile with edition 2021 despite all having been updated in the same upstream PR. Was this intentional, or just an omission?
Hmm... I guess we overfocused on core here given it was about fixing that for the main build, and I applied the change of the edition for rust-analyzer too, but then we didn't update the others, but hard to say.
I see you replied in the linked Zulip and sent the patches -- thanks for taking a look!
Cheers,
Miguel