authorbors <bors@rust-lang.org> 2025-09-27 22:30:56 UTC
committerbors <bors@rust-lang.org> 2025-09-27 22:30:56 UTC
log848e6746fe03dfd703075c5077312b63877d51d6
treeeba347843510a17e763b7a896a3955759784b546
parent4082d6a3f0347c2fc4b8c8d5a6a38ed7248fa161
parentbd2e18671d4eb0c2cf33965748c270a8ec358557

Auto merge of #147104 - matthiaskrgr:rollup-gap1v0w, r=matthiaskrgr

Rollup of 8 pull requests Successful merges: - rust-lang/rust#146037 (Introduce CoerceShared lang item and trait, and basic Reborrow tests) - rust-lang/rust#146732 (tests: relax expectations after llvm change 902ddda120a5) - rust-lang/rust#147018 (re-order normalizations in run-make linker-warning test) - rust-lang/rust#147032 (Fix doctest compilation time display) - rust-lang/rust#147046 (Rename `rust.use-lld` to `rust.bootstrap-override-lld`) - rust-lang/rust#147050 (PassWrapper: update for new PGOOptions args in LLVM 22) - rust-lang/rust#147075 (Make `def_path_hash_to_def_id` not panic when passed an invalid hash) - rust-lang/rust#147076 (update issue number for more_float_constants) r? `@ghost` `@rustbot` modify labels: rollup

55 files changed, 576 insertions(+), 114 deletions(-)

bootstrap.example.toml+3-4
......@@ -768,8 +768,7 @@
768768# make this default to false.
769769#rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true
770770
771# Indicates whether LLD will be used to link Rust crates during bootstrap on
772# supported platforms.
771# Indicates if we should override the linker used to link Rust crates during bootstrap to be LLD.
773772# If set to `true` or `"external"`, a global `lld` binary that has to be in $PATH
774773# will be used.
775774# If set to `"self-contained"`, rust-lld from the snapshot compiler will be used.
......@@ -777,7 +776,7 @@
777776# On MSVC, LLD will not be used if we're cross linking.
778777#
779778# Explicitly setting the linker for a target will override this option when targeting MSVC.
780#rust.use-lld = false
779#rust.bootstrap-override-lld = false
781780
782781# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
783782# sysroot.
......@@ -950,7 +949,7 @@
950949# Linker to be used to bootstrap Rust code. Note that the
951950# default value is platform specific, and if not specified it may also depend on
952951# what platform is crossing to what platform.
953# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
952# Setting this will override the `bootstrap-override-lld` option for Rust code when targeting MSVC.
954953#linker = "cc" (path)
955954
956955# Should rustc and the standard library be built with split debuginfo? Default
compiler/rustc_hir/src/lang_items.rs+1
......@@ -440,6 +440,7 @@ language_item_table! {
440440
441441 // Reborrowing related lang-items
442442 Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0);
443 CoerceShared, sym::coerce_shared, coerce_shared, Target::Trait, GenericRequirement::Exact(0);
443444}
444445
445446/// The requirement imposed on the generics of a lang item
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp+18
......@@ -569,25 +569,43 @@ extern "C" LLVMRustResult LLVMRustOptimize(
569569 }
570570
571571 std::optional<PGOOptions> PGOOpt;
572#if LLVM_VERSION_LT(22, 0)
572573 auto FS = vfs::getRealFileSystem();
574#endif
573575 if (PGOGenPath) {
574576 assert(!PGOUsePath && !PGOSampleUsePath);
575577 PGOOpt = PGOOptions(
578#if LLVM_VERSION_GE(22, 0)
579 PGOGenPath, "", "", "", PGOOptions::IRInstr, PGOOptions::NoCSAction,
580#else
576581 PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction,
582#endif
577583 PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
578584 } else if (PGOUsePath) {
579585 assert(!PGOSampleUsePath);
580586 PGOOpt = PGOOptions(
587#if LLVM_VERSION_GE(22, 0)
588 PGOUsePath, "", "", "", PGOOptions::IRUse, PGOOptions::NoCSAction,
589#else
581590 PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction,
591#endif
582592 PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
583593 } else if (PGOSampleUsePath) {
584594 PGOOpt =
595#if LLVM_VERSION_GE(22, 0)
596 PGOOptions(PGOSampleUsePath, "", "", "", PGOOptions::SampleUse,
597#else
585598 PGOOptions(PGOSampleUsePath, "", "", "", FS, PGOOptions::SampleUse,
599#endif
586600 PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
587601 DebugInfoForProfiling);
588602 } else if (DebugInfoForProfiling) {
589603 PGOOpt = PGOOptions(
604#if LLVM_VERSION_GE(22, 0)
605 "", "", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
606#else
590607 "", "", "", "", FS, PGOOptions::NoAction, PGOOptions::NoCSAction,
608#endif
591609 PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
592610 }
593611
compiler/rustc_metadata/src/rmeta/decoder.rs+1-1
......@@ -1555,7 +1555,7 @@ impl<'a> CrateMetadataRef<'a> {
15551555 }
15561556
15571557 #[inline]
1558 fn def_path_hash_to_def_index(self, hash: DefPathHash) -> DefIndex {
1558 fn def_path_hash_to_def_index(self, hash: DefPathHash) -> Option<DefIndex> {
15591559 self.def_path_hash_map.def_path_hash_to_def_index(&hash)
15601560 }
15611561
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs+2-2
......@@ -691,8 +691,8 @@ fn provide_cstore_hooks(providers: &mut Providers) {
691691 .get(&stable_crate_id)
692692 .unwrap_or_else(|| bug!("uninterned StableCrateId: {stable_crate_id:?}"));
693693 assert_ne!(cnum, LOCAL_CRATE);
694 let def_index = cstore.get_crate_data(cnum).def_path_hash_to_def_index(hash);
695 DefId { krate: cnum, index: def_index }
694 let def_index = cstore.get_crate_data(cnum).def_path_hash_to_def_index(hash)?;
695 Some(DefId { krate: cnum, index: def_index })
696696 };
697697
698698 providers.hooks.expn_hash_to_expn_id = |tcx, cnum, index_guess, hash| {
compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs+5-4
......@@ -12,11 +12,12 @@ pub(crate) enum DefPathHashMapRef<'tcx> {
1212
1313impl DefPathHashMapRef<'_> {
1414 #[inline]
15 pub(crate) fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
15 pub(crate) fn def_path_hash_to_def_index(
16 &self,
17 def_path_hash: &DefPathHash,
18 ) -> Option<DefIndex> {
1619 match *self {
17 DefPathHashMapRef::OwnedFromMetadata(ref map) => {
18 map.get(&def_path_hash.local_hash()).unwrap()
19 }
20 DefPathHashMapRef::OwnedFromMetadata(ref map) => map.get(&def_path_hash.local_hash()),
2021 DefPathHashMapRef::BorrowedFromTcx(_) => {
2122 panic!("DefPathHashMap::BorrowedFromTcx variant only exists for serialization")
2223 }
compiler/rustc_middle/src/hooks/mod.rs+1-1
......@@ -77,7 +77,7 @@ declare_hooks! {
7777 /// session, if it still exists. This is used during incremental compilation to
7878 /// turn a deserialized `DefPathHash` into its current `DefId`.
7979 /// Will fetch a DefId from a DefPathHash for a foreign crate.
80 hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId;
80 hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> Option<DefId>;
8181
8282 /// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
8383 /// can just link to the upstream crate and therefore don't need a mono item.
compiler/rustc_middle/src/ty/context.rs+1-1
......@@ -2012,7 +2012,7 @@ impl<'tcx> TyCtxt<'tcx> {
20122012 if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) {
20132013 Some(self.untracked.definitions.read().local_def_path_hash_to_def_id(hash)?.to_def_id())
20142014 } else {
2015 Some(self.def_path_hash_to_def_id_extern(hash, stable_crate_id))
2015 self.def_path_hash_to_def_id_extern(hash, stable_crate_id)
20162016 }
20172017 }
20182018
compiler/rustc_span/src/symbol.rs+1
......@@ -679,6 +679,7 @@ symbols! {
679679 cmpxchg16b_target_feature,
680680 cmse_nonsecure_entry,
681681 coerce_pointee_validated,
682 coerce_shared,
682683 coerce_unsized,
683684 cold,
684685 cold_path,
library/core/src/marker.rs-8
......@@ -1341,11 +1341,3 @@ pub macro CoercePointee($item:item) {
13411341pub trait CoercePointeeValidated {
13421342 /* compiler built-in */
13431343}
1344
1345/// Allows value to be reborrowed as exclusive, creating a copy of the value
1346/// that disables the source for reads and writes for the lifetime of the copy.
1347#[lang = "reborrow"]
1348#[unstable(feature = "reborrow", issue = "145612")]
1349pub trait Reborrow {
1350 // Empty.
1351}
library/core/src/num/f128.rs+6-6
......@@ -33,12 +33,12 @@ pub mod consts {
3333
3434 /// The golden ratio (φ)
3535 #[unstable(feature = "f128", issue = "116909")]
36 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
36 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
3737 pub const PHI: f128 = 1.61803398874989484820458683436563811772030917980576286213545_f128;
3838
3939 /// The Euler-Mascheroni constant (γ)
4040 #[unstable(feature = "f128", issue = "116909")]
41 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
41 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
4242 pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128;
4343
4444 /// π/2
......@@ -67,14 +67,14 @@ pub mod consts {
6767
6868 /// 1/sqrt(π)
6969 #[unstable(feature = "f128", issue = "116909")]
70 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
70 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
7171 pub const FRAC_1_SQRT_PI: f128 =
7272 0.564189583547756286948079451560772585844050629328998856844086_f128;
7373
7474 /// 1/sqrt(2π)
7575 #[doc(alias = "FRAC_1_SQRT_TAU")]
7676 #[unstable(feature = "f128", issue = "116909")]
77 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
77 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
7878 pub const FRAC_1_SQRT_2PI: f128 =
7979 0.398942280401432677939946059934381868475858631164934657665926_f128;
8080
......@@ -98,12 +98,12 @@ pub mod consts {
9898
9999 /// sqrt(3)
100100 #[unstable(feature = "f128", issue = "116909")]
101 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
101 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
102102 pub const SQRT_3: f128 = 1.73205080756887729352744634150587236694280525381038062805581_f128;
103103
104104 /// 1/sqrt(3)
105105 #[unstable(feature = "f128", issue = "116909")]
106 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
106 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
107107 pub const FRAC_1_SQRT_3: f128 =
108108 0.577350269189625764509148780501957455647601751270126876018602_f128;
109109
library/core/src/num/f16.rs+6-6
......@@ -35,12 +35,12 @@ pub mod consts {
3535
3636 /// The golden ratio (φ)
3737 #[unstable(feature = "f16", issue = "116909")]
38 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
38 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
3939 pub const PHI: f16 = 1.618033988749894848204586834365638118_f16;
4040
4141 /// The Euler-Mascheroni constant (γ)
4242 #[unstable(feature = "f16", issue = "116909")]
43 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
43 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
4444 pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16;
4545
4646 /// π/2
......@@ -69,13 +69,13 @@ pub mod consts {
6969
7070 /// 1/sqrt(π)
7171 #[unstable(feature = "f16", issue = "116909")]
72 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
72 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
7373 pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16;
7474
7575 /// 1/sqrt(2π)
7676 #[doc(alias = "FRAC_1_SQRT_TAU")]
7777 #[unstable(feature = "f16", issue = "116909")]
78 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
78 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
7979 pub const FRAC_1_SQRT_2PI: f16 = 0.398942280401432677939946059934381868_f16;
8080
8181 /// 2/π
......@@ -96,12 +96,12 @@ pub mod consts {
9696
9797 /// sqrt(3)
9898 #[unstable(feature = "f16", issue = "116909")]
99 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
99 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
100100 pub const SQRT_3: f16 = 1.732050807568877293527446341505872367_f16;
101101
102102 /// 1/sqrt(3)
103103 #[unstable(feature = "f16", issue = "116909")]
104 // Also, #[unstable(feature = "more_float_constants", issue = "103883")]
104 // Also, #[unstable(feature = "more_float_constants", issue = "146939")]
105105 pub const FRAC_1_SQRT_3: f16 = 0.577350269189625764509148780501957456_f16;
106106
107107 /// Euler's number (e)
library/core/src/num/f32.rs+6-6
......@@ -291,11 +291,11 @@ pub mod consts {
291291 pub const TAU: f32 = 6.28318530717958647692528676655900577_f32;
292292
293293 /// The golden ratio (φ)
294 #[unstable(feature = "more_float_constants", issue = "103883")]
294 #[unstable(feature = "more_float_constants", issue = "146939")]
295295 pub const PHI: f32 = 1.618033988749894848204586834365638118_f32;
296296
297297 /// The Euler-Mascheroni constant (γ)
298 #[unstable(feature = "more_float_constants", issue = "103883")]
298 #[unstable(feature = "more_float_constants", issue = "146939")]
299299 pub const EGAMMA: f32 = 0.577215664901532860606512090082402431_f32;
300300
301301 /// π/2
......@@ -323,12 +323,12 @@ pub mod consts {
323323 pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32;
324324
325325 /// 1/sqrt(π)
326 #[unstable(feature = "more_float_constants", issue = "103883")]
326 #[unstable(feature = "more_float_constants", issue = "146939")]
327327 pub const FRAC_1_SQRT_PI: f32 = 0.564189583547756286948079451560772586_f32;
328328
329329 /// 1/sqrt(2π)
330330 #[doc(alias = "FRAC_1_SQRT_TAU")]
331 #[unstable(feature = "more_float_constants", issue = "103883")]
331 #[unstable(feature = "more_float_constants", issue = "146939")]
332332 pub const FRAC_1_SQRT_2PI: f32 = 0.398942280401432677939946059934381868_f32;
333333
334334 /// 2/π
......@@ -348,11 +348,11 @@ pub mod consts {
348348 pub const FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039_f32;
349349
350350 /// sqrt(3)
351 #[unstable(feature = "more_float_constants", issue = "103883")]
351 #[unstable(feature = "more_float_constants", issue = "146939")]
352352 pub const SQRT_3: f32 = 1.732050807568877293527446341505872367_f32;
353353
354354 /// 1/sqrt(3)
355 #[unstable(feature = "more_float_constants", issue = "103883")]
355 #[unstable(feature = "more_float_constants", issue = "146939")]
356356 pub const FRAC_1_SQRT_3: f32 = 0.577350269189625764509148780501957456_f32;
357357
358358 /// Euler's number (e)
library/core/src/num/f64.rs+6-6
......@@ -291,11 +291,11 @@ pub mod consts {
291291 pub const TAU: f64 = 6.28318530717958647692528676655900577_f64;
292292
293293 /// The golden ratio (φ)
294 #[unstable(feature = "more_float_constants", issue = "103883")]
294 #[unstable(feature = "more_float_constants", issue = "146939")]
295295 pub const PHI: f64 = 1.618033988749894848204586834365638118_f64;
296296
297297 /// The Euler-Mascheroni constant (γ)
298 #[unstable(feature = "more_float_constants", issue = "103883")]
298 #[unstable(feature = "more_float_constants", issue = "146939")]
299299 pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64;
300300
301301 /// π/2
......@@ -323,12 +323,12 @@ pub mod consts {
323323 pub const FRAC_1_PI: f64 = 0.318309886183790671537767526745028724_f64;
324324
325325 /// 1/sqrt(π)
326 #[unstable(feature = "more_float_constants", issue = "103883")]
326 #[unstable(feature = "more_float_constants", issue = "146939")]
327327 pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64;
328328
329329 /// 1/sqrt(2π)
330330 #[doc(alias = "FRAC_1_SQRT_TAU")]
331 #[unstable(feature = "more_float_constants", issue = "103883")]
331 #[unstable(feature = "more_float_constants", issue = "146939")]
332332 pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64;
333333
334334 /// 2/π
......@@ -348,11 +348,11 @@ pub mod consts {
348348 pub const FRAC_1_SQRT_2: f64 = 0.707106781186547524400844362104849039_f64;
349349
350350 /// sqrt(3)
351 #[unstable(feature = "more_float_constants", issue = "103883")]
351 #[unstable(feature = "more_float_constants", issue = "146939")]
352352 pub const SQRT_3: f64 = 1.732050807568877293527446341505872367_f64;
353353
354354 /// 1/sqrt(3)
355 #[unstable(feature = "more_float_constants", issue = "103883")]
355 #[unstable(feature = "more_float_constants", issue = "146939")]
356356 pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64;
357357
358358 /// Euler's number (e)
library/core/src/ops/mod.rs+3
......@@ -149,6 +149,7 @@ mod function;
149149mod index;
150150mod index_range;
151151mod range;
152mod reborrow;
152153mod try_trait;
153154mod unsize;
154155
......@@ -189,6 +190,8 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
189190pub use self::range::{OneSidedRange, OneSidedRangeBound};
190191#[stable(feature = "rust1", since = "1.0.0")]
191192pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
193#[unstable(feature = "reborrow", issue = "145612")]
194pub use self::reborrow::{CoerceShared, Reborrow};
192195#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
193196pub use self::try_trait::Residual;
194197#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
library/core/src/ops/reborrow.rs created+16
......@@ -0,0 +1,16 @@
1/// Allows value to be reborrowed as exclusive, creating a copy of the value
2/// that disables the source for reads and writes for the lifetime of the copy.
3#[lang = "reborrow"]
4#[unstable(feature = "reborrow", issue = "145612")]
5pub trait Reborrow {
6 // Empty.
7}
8
9/// Allows reborrowable value to be reborrowed as shared, creating a copy
10/// that disables the source for writes for the lifetime of the copy.
11#[lang = "coerce_shared"]
12#[unstable(feature = "reborrow", issue = "145612")]
13pub trait CoerceShared: Reborrow {
14 /// The type of this value when reborrowed as shared.
15 type Target: Copy;
16}
src/bootstrap/src/core/build_steps/compile.rs+2-2
......@@ -1221,7 +1221,7 @@ pub fn rustc_cargo(
12211221 // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object
12221222 // with direct references to protected symbols, so for now we only use protected symbols if
12231223 // linking with LLD is enabled.
1224 if builder.build.config.lld_mode.is_used() {
1224 if builder.build.config.bootstrap_override_lld.is_used() {
12251225 cargo.rustflag("-Zdefault-visibility=protected");
12261226 }
12271227
......@@ -1258,7 +1258,7 @@ pub fn rustc_cargo(
12581258 // is already on by default in MSVC optimized builds, which is interpreted as --icf=all:
12591259 // https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746
12601260 // https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827
1261 if builder.config.lld_mode.is_used() && !build_compiler.host.is_msvc() {
1261 if builder.config.bootstrap_override_lld.is_used() && !build_compiler.host.is_msvc() {
12621262 cargo.rustflag("-Clink-args=-Wl,--icf=all");
12631263 }
12641264
src/bootstrap/src/core/config/config.rs+15-5
......@@ -41,7 +41,7 @@ use crate::core::config::toml::gcc::Gcc;
4141use crate::core::config::toml::install::Install;
4242use crate::core::config::toml::llvm::Llvm;
4343use crate::core::config::toml::rust::{
44 LldMode, Rust, RustOptimize, check_incompatible_options_for_ci_rustc,
44 BootstrapOverrideLld, Rust, RustOptimize, check_incompatible_options_for_ci_rustc,
4545 default_lld_opt_in_targets, parse_codegen_backends,
4646};
4747use crate::core::config::toml::target::Target;
......@@ -174,7 +174,7 @@ pub struct Config {
174174 pub llvm_from_ci: bool,
175175 pub llvm_build_config: HashMap<String, String>,
176176
177 pub lld_mode: LldMode,
177 pub bootstrap_override_lld: BootstrapOverrideLld,
178178 pub lld_enabled: bool,
179179 pub llvm_tools_enabled: bool,
180180 pub llvm_bitcode_linker_enabled: bool,
......@@ -567,7 +567,8 @@ impl Config {
567567 frame_pointers: rust_frame_pointers,
568568 stack_protector: rust_stack_protector,
569569 strip: rust_strip,
570 lld_mode: rust_lld_mode,
570 bootstrap_override_lld: rust_bootstrap_override_lld,
571 bootstrap_override_lld_legacy: rust_bootstrap_override_lld_legacy,
571572 std_features: rust_std_features,
572573 break_on_ice: rust_break_on_ice,
573574 } = toml.rust.unwrap_or_default();
......@@ -615,6 +616,15 @@ impl Config {
615616
616617 let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default();
617618
619 if rust_bootstrap_override_lld.is_some() && rust_bootstrap_override_lld_legacy.is_some() {
620 panic!(
621 "Cannot use both `rust.use-lld` and `rust.bootstrap-override-lld`. Please use only `rust.bootstrap-override-lld`"
622 );
623 }
624
625 let bootstrap_override_lld =
626 rust_bootstrap_override_lld.or(rust_bootstrap_override_lld_legacy).unwrap_or_default();
627
618628 if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) {
619629 eprintln!(
620630 "WARNING: setting `optimize` to `false` is known to cause errors and \
......@@ -960,7 +970,7 @@ impl Config {
960970
961971 let initial_rustfmt = build_rustfmt.or_else(|| maybe_download_rustfmt(&dwn_ctx, &out));
962972
963 if matches!(rust_lld_mode.unwrap_or_default(), LldMode::SelfContained)
973 if matches!(bootstrap_override_lld, BootstrapOverrideLld::SelfContained)
964974 && !lld_enabled
965975 && flags_stage.unwrap_or(0) > 0
966976 {
......@@ -1172,6 +1182,7 @@ impl Config {
11721182 backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false),
11731183 bindir: install_bindir.map(PathBuf::from).unwrap_or("bin".into()),
11741184 bootstrap_cache_path: build_bootstrap_cache_path,
1185 bootstrap_override_lld,
11751186 bypass_bootstrap_lock: flags_bypass_bootstrap_lock,
11761187 cargo_info,
11771188 cargo_native_static: build_cargo_native_static.unwrap_or(false),
......@@ -1238,7 +1249,6 @@ impl Config {
12381249 libdir: install_libdir.map(PathBuf::from),
12391250 library_docs_private_items: build_library_docs_private_items.unwrap_or(false),
12401251 lld_enabled,
1241 lld_mode: rust_lld_mode.unwrap_or_default(),
12421252 lldb: build_lldb.map(PathBuf::from),
12431253 llvm_allow_old_toolchain: llvm_allow_old_toolchain.unwrap_or(false),
12441254 llvm_assertions,
src/bootstrap/src/core/config/mod.rs+1-1
......@@ -37,7 +37,7 @@ use serde_derive::Deserialize;
3737pub use target_selection::TargetSelection;
3838pub use toml::BUILDER_CONFIG_FILENAME;
3939pub use toml::change_id::ChangeId;
40pub use toml::rust::LldMode;
40pub use toml::rust::BootstrapOverrideLld;
4141pub use toml::target::Target;
4242
4343use crate::Display;
src/bootstrap/src/core/config/tests.rs+30-6
......@@ -17,7 +17,9 @@ use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1717use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
1818use crate::core::build_steps::{llvm, test};
1919use crate::core::config::toml::TomlConfig;
20use crate::core::config::{CompilerBuiltins, LldMode, StringOrBool, Target, TargetSelection};
20use crate::core::config::{
21 BootstrapOverrideLld, CompilerBuiltins, StringOrBool, Target, TargetSelection,
22};
2123use crate::utils::tests::TestCtx;
2224use crate::utils::tests::git::git_test;
2325
......@@ -222,11 +224,33 @@ fn verify_file_integrity() {
222224
223225#[test]
224226fn rust_lld() {
225 assert!(matches!(parse("").lld_mode, LldMode::Unused));
226 assert!(matches!(parse("rust.use-lld = \"self-contained\"").lld_mode, LldMode::SelfContained));
227 assert!(matches!(parse("rust.use-lld = \"external\"").lld_mode, LldMode::External));
228 assert!(matches!(parse("rust.use-lld = true").lld_mode, LldMode::External));
229 assert!(matches!(parse("rust.use-lld = false").lld_mode, LldMode::Unused));
227 assert!(matches!(parse("").bootstrap_override_lld, BootstrapOverrideLld::None));
228 assert!(matches!(
229 parse("rust.bootstrap-override-lld = \"self-contained\"").bootstrap_override_lld,
230 BootstrapOverrideLld::SelfContained
231 ));
232 assert!(matches!(
233 parse("rust.bootstrap-override-lld = \"external\"").bootstrap_override_lld,
234 BootstrapOverrideLld::External
235 ));
236 assert!(matches!(
237 parse("rust.bootstrap-override-lld = true").bootstrap_override_lld,
238 BootstrapOverrideLld::External
239 ));
240 assert!(matches!(
241 parse("rust.bootstrap-override-lld = false").bootstrap_override_lld,
242 BootstrapOverrideLld::None
243 ));
244
245 // Also check the legacy options
246 assert!(matches!(
247 parse("rust.use-lld = true").bootstrap_override_lld,
248 BootstrapOverrideLld::External
249 ));
250 assert!(matches!(
251 parse("rust.use-lld = false").bootstrap_override_lld,
252 BootstrapOverrideLld::None
253 ));
230254}
231255
232256#[test]
src/bootstrap/src/core/config/toml/rust.rs+31-18
......@@ -45,7 +45,9 @@ define_config! {
4545 codegen_backends: Option<Vec<String>> = "codegen-backends",
4646 llvm_bitcode_linker: Option<bool> = "llvm-bitcode-linker",
4747 lld: Option<bool> = "lld",
48 lld_mode: Option<LldMode> = "use-lld",
48 bootstrap_override_lld: Option<BootstrapOverrideLld> = "bootstrap-override-lld",
49 // FIXME: Remove this option in Spring 2026
50 bootstrap_override_lld_legacy: Option<BootstrapOverrideLld> = "use-lld",
4951 llvm_tools: Option<bool> = "llvm-tools",
5052 deny_warnings: Option<bool> = "deny-warnings",
5153 backtrace_on_ice: Option<bool> = "backtrace-on-ice",
......@@ -70,22 +72,33 @@ define_config! {
7072 }
7173}
7274
73/// LLD in bootstrap works like this:
74/// - Self-contained lld: use `rust-lld` from the compiler's sysroot
75/// Determines if we should override the linker used for linking Rust code built
76/// during the bootstrapping process to be LLD.
77///
78/// The primary use-case for this is to make local (re)builds of Rust code faster
79/// when using bootstrap.
80///
81/// This does not affect the *behavior* of the built/distributed compiler when invoked
82/// outside of bootstrap.
83/// It might affect its performance/binary size though, as that can depend on the
84/// linker that links rustc.
85///
86/// There are two ways of overriding the linker to be LLD:
87/// - Self-contained LLD: use `rust-lld` from the compiler's sysroot
7588/// - External: use an external `lld` binary
7689///
7790/// It is configured depending on the target:
7891/// 1) Everything except MSVC
79/// - Self-contained: `-Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker`
80/// - External: `-Clinker-flavor=gnu-lld-cc`
92/// - Self-contained: `-Clinker-features=+lld -Clink-self-contained=+linker`
93/// - External: `-Clinker-features=+lld`
8194/// 2) MSVC
8295/// - Self-contained: `-Clinker=<path to rust-lld>`
8396/// - External: `-Clinker=lld`
8497#[derive(Copy, Clone, Default, Debug, PartialEq)]
85pub enum LldMode {
86 /// Do not use LLD
98pub enum BootstrapOverrideLld {
99 /// Do not override the linker LLD
87100 #[default]
88 Unused,
101 None,
89102 /// Use `rust-lld` from the compiler's sysroot
90103 SelfContained,
91104 /// Use an externally provided `lld` binary.
......@@ -94,16 +107,16 @@ pub enum LldMode {
94107 External,
95108}
96109
97impl LldMode {
110impl BootstrapOverrideLld {
98111 pub fn is_used(&self) -> bool {
99112 match self {
100 LldMode::SelfContained | LldMode::External => true,
101 LldMode::Unused => false,
113 BootstrapOverrideLld::SelfContained | BootstrapOverrideLld::External => true,
114 BootstrapOverrideLld::None => false,
102115 }
103116 }
104117}
105118
106impl<'de> Deserialize<'de> for LldMode {
119impl<'de> Deserialize<'de> for BootstrapOverrideLld {
107120 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
108121 where
109122 D: Deserializer<'de>,
......@@ -111,7 +124,7 @@ impl<'de> Deserialize<'de> for LldMode {
111124 struct LldModeVisitor;
112125
113126 impl serde::de::Visitor<'_> for LldModeVisitor {
114 type Value = LldMode;
127 type Value = BootstrapOverrideLld;
115128
116129 fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
117130 formatter.write_str("one of true, 'self-contained' or 'external'")
......@@ -121,7 +134,7 @@ impl<'de> Deserialize<'de> for LldMode {
121134 where
122135 E: serde::de::Error,
123136 {
124 Ok(if v { LldMode::External } else { LldMode::Unused })
137 Ok(if v { BootstrapOverrideLld::External } else { BootstrapOverrideLld::None })
125138 }
126139
127140 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
......@@ -129,8 +142,8 @@ impl<'de> Deserialize<'de> for LldMode {
129142 E: serde::de::Error,
130143 {
131144 match v {
132 "external" => Ok(LldMode::External),
133 "self-contained" => Ok(LldMode::SelfContained),
145 "external" => Ok(BootstrapOverrideLld::External),
146 "self-contained" => Ok(BootstrapOverrideLld::SelfContained),
134147 _ => Err(E::custom(format!("unknown mode {v}"))),
135148 }
136149 }
......@@ -311,7 +324,6 @@ pub fn check_incompatible_options_for_ci_rustc(
311324 lto,
312325 stack_protector,
313326 strip,
314 lld_mode,
315327 jemalloc,
316328 rpath,
317329 channel,
......@@ -359,6 +371,8 @@ pub fn check_incompatible_options_for_ci_rustc(
359371 frame_pointers: _,
360372 break_on_ice: _,
361373 parallel_frontend_threads: _,
374 bootstrap_override_lld: _,
375 bootstrap_override_lld_legacy: _,
362376 } = ci_rust_config;
363377
364378 // There are two kinds of checks for CI rustc incompatible options:
......@@ -374,7 +388,6 @@ pub fn check_incompatible_options_for_ci_rustc(
374388 err!(current_rust_config.debuginfo_level_rustc, debuginfo_level_rustc, "rust");
375389 err!(current_rust_config.rpath, rpath, "rust");
376390 err!(current_rust_config.strip, strip, "rust");
377 err!(current_rust_config.lld_mode, lld_mode, "rust");
378391 err!(current_rust_config.llvm_tools, llvm_tools, "rust");
379392 err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust");
380393 err!(current_rust_config.jemalloc, jemalloc, "rust");
src/bootstrap/src/lib.rs+6-6
......@@ -35,7 +35,7 @@ use utils::exec::ExecutionContext;
3535
3636use crate::core::builder;
3737use crate::core::builder::Kind;
38use crate::core::config::{DryRun, LldMode, LlvmLibunwind, TargetSelection, flags};
38use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags};
3939use crate::utils::exec::{BootstrapCommand, command};
4040use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo};
4141
......@@ -1358,14 +1358,14 @@ impl Build {
13581358 && !target.is_msvc()
13591359 {
13601360 Some(self.cc(target))
1361 } else if self.config.lld_mode.is_used()
1361 } else if self.config.bootstrap_override_lld.is_used()
13621362 && self.is_lld_direct_linker(target)
13631363 && self.host_target == target
13641364 {
1365 match self.config.lld_mode {
1366 LldMode::SelfContained => Some(self.initial_lld.clone()),
1367 LldMode::External => Some("lld".into()),
1368 LldMode::Unused => None,
1365 match self.config.bootstrap_override_lld {
1366 BootstrapOverrideLld::SelfContained => Some(self.initial_lld.clone()),
1367 BootstrapOverrideLld::External => Some("lld".into()),
1368 BootstrapOverrideLld::None => None,
13691369 }
13701370 } else {
13711371 None
src/bootstrap/src/utils/change_tracker.rs+5
......@@ -556,4 +556,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
556556 severity: ChangeSeverity::Info,
557557 summary: "New option `build.windows-rc` that will override which resource compiler on Windows will be used to compile Rust.",
558558 },
559 ChangeInfo {
560 change_id: 99999,
561 severity: ChangeSeverity::Warning,
562 summary: "The `rust.use-lld` option has been renamed to `rust.bootstrap-override-lld`. Note that it only serves for overriding the linker used when building Rust code in bootstrap to be LLD.",
563 },
559564];
src/bootstrap/src/utils/helpers.rs+18-10
......@@ -12,7 +12,7 @@ use std::{env, fs, io, panic, str};
1212
1313use object::read::archive::ArchiveFile;
1414
15use crate::LldMode;
15use crate::BootstrapOverrideLld;
1616use crate::core::builder::Builder;
1717use crate::core::config::{Config, TargetSelection};
1818use crate::utils::exec::{BootstrapCommand, command};
......@@ -357,15 +357,19 @@ pub fn get_clang_cl_resource_dir(builder: &Builder<'_>, clang_cl_path: &str) ->
357357/// Returns a flag that configures LLD to use only a single thread.
358358/// If we use an external LLD, we need to find out which version is it to know which flag should we
359359/// pass to it (LLD older than version 10 had a different flag).
360fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: bool) -> &'static str {
360fn lld_flag_no_threads(
361 builder: &Builder<'_>,
362 bootstrap_override_lld: BootstrapOverrideLld,
363 is_windows: bool,
364) -> &'static str {
361365 static LLD_NO_THREADS: OnceLock<(&'static str, &'static str)> = OnceLock::new();
362366
363367 let new_flags = ("/threads:1", "--threads=1");
364368 let old_flags = ("/no-threads", "--no-threads");
365369
366370 let (windows_flag, other_flag) = LLD_NO_THREADS.get_or_init(|| {
367 let newer_version = match lld_mode {
368 LldMode::External => {
371 let newer_version = match bootstrap_override_lld {
372 BootstrapOverrideLld::External => {
369373 let mut cmd = command("lld");
370374 cmd.arg("-flavor").arg("ld").arg("--version");
371375 let out = cmd.run_capture_stdout(builder).stdout();
......@@ -422,24 +426,28 @@ pub fn linker_flags(
422426 lld_threads: LldThreads,
423427) -> Vec<String> {
424428 let mut args = vec![];
425 if !builder.is_lld_direct_linker(target) && builder.config.lld_mode.is_used() {
426 match builder.config.lld_mode {
427 LldMode::External => {
429 if !builder.is_lld_direct_linker(target) && builder.config.bootstrap_override_lld.is_used() {
430 match builder.config.bootstrap_override_lld {
431 BootstrapOverrideLld::External => {
428432 args.push("-Clinker-features=+lld".to_string());
429433 args.push("-Zunstable-options".to_string());
430434 }
431 LldMode::SelfContained => {
435 BootstrapOverrideLld::SelfContained => {
432436 args.push("-Clinker-features=+lld".to_string());
433437 args.push("-Clink-self-contained=+linker".to_string());
434438 args.push("-Zunstable-options".to_string());
435439 }
436 LldMode::Unused => unreachable!(),
440 BootstrapOverrideLld::None => unreachable!(),
437441 };
438442
439443 if matches!(lld_threads, LldThreads::No) {
440444 args.push(format!(
441445 "-Clink-arg=-Wl,{}",
442 lld_flag_no_threads(builder, builder.config.lld_mode, target.is_windows())
446 lld_flag_no_threads(
447 builder,
448 builder.config.bootstrap_override_lld,
449 target.is_windows()
450 )
443451 ));
444452 }
445453 }
src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile+1-1
......@@ -91,7 +91,7 @@ ENV RUST_CONFIGURE_ARGS \
9191 --set llvm.ninja=false \
9292 --set rust.debug-assertions=false \
9393 --set rust.jemalloc \
94 --set rust.use-lld=true \
94 --set rust.bootstrap-override-lld=true \
9595 --set rust.lto=thin \
9696 --set rust.codegen-units=1
9797
src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile+1-1
......@@ -92,7 +92,7 @@ ENV RUST_CONFIGURE_ARGS \
9292 --set llvm.ninja=false \
9393 --set llvm.libzstd=true \
9494 --set rust.jemalloc \
95 --set rust.use-lld=true \
95 --set rust.bootstrap-override-lld=true \
9696 --set rust.lto=thin \
9797 --set rust.codegen-units=1
9898
src/librustdoc/doctest.rs+7-3
......@@ -404,11 +404,15 @@ pub(crate) fn run_tests(
404404 std::mem::drop(temp_dir.take());
405405 times.display_times();
406406 });
407 } else {
408 // If the first condition branch exited successfully, `test_main_with_exit_callback` will
409 // not exit the process. So to prevent displaying the times twice, we put it behind an
410 // `else` condition.
411 times.display_times();
407412 }
413 // We ensure temp dir destructor is called.
414 std::mem::drop(temp_dir);
408415 if nb_errors != 0 {
409 // We ensure temp dir destructor is called.
410 std::mem::drop(temp_dir);
411 times.display_times();
412416 std::process::exit(test::ERROR_EXIT_CODE);
413417 }
414418}
tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs+5-2
......@@ -1,4 +1,7 @@
11//@ compile-flags: -Copt-level=3
2//@ revisions: new old
3//@ [old] max-llvm-major-version: 21
4//@ [new] min-llvm-version: 22
25
36#![crate_type = "lib"]
47
......@@ -22,8 +25,8 @@ pub unsafe fn update(s: *mut State) {
2225 // CHECK-NOT: memcpy
2326 // CHECK-NOT: 75{{3|4}}
2427
25 // CHECK: %[[TAG:.+]] = load i8, ptr %s, align 1
26 // CHECK-NEXT: trunc nuw i8 %[[TAG]] to i1
28 // old: %[[TAG:.+]] = load i8, ptr %s, align 1
29 // old-NEXT: trunc nuw i8 %[[TAG]] to i1
2730
2831 // CHECK-NOT: load
2932 // CHECK-NOT: store
tests/codegen-llvm/vec_pop_push_noop.rs+4-1
......@@ -1,4 +1,7 @@
11//@ compile-flags: -Copt-level=3
2//@ revisions: new old
3//@ [old] max-llvm-major-version: 21
4//@ [new] min-llvm-version: 22
25
36#![crate_type = "lib"]
47
......@@ -7,7 +10,7 @@
710pub fn noop(v: &mut Vec<u8>) {
811 // CHECK-NOT: grow_one
912 // CHECK-NOT: call
10 // CHECK: tail call void @llvm.assume
13 // old: tail call void @llvm.assume
1114 // CHECK-NOT: grow_one
1215 // CHECK-NOT: call
1316 // CHECK: {{ret|[}]}}
tests/codegen-llvm/vecdeque_pop_push.rs+4-1
......@@ -1,4 +1,7 @@
11//@ compile-flags: -Copt-level=3
2//@ revisions: new old
3//@ [old] max-llvm-major-version: 21
4//@ [new] min-llvm-version: 22
25
36#![crate_type = "lib"]
47
......@@ -8,7 +11,7 @@ use std::collections::VecDeque;
811// CHECK-LABEL: @noop_back(
912pub fn noop_back(v: &mut VecDeque<u8>) {
1013 // CHECK-NOT: grow
11 // CHECK: tail call void @llvm.assume
14 // old: tail call void @llvm.assume
1215 // CHECK-NOT: grow
1316 // CHECK: ret
1417 if let Some(x) = v.pop_back() {
tests/run-make/doctests-compilation-time-info/rmake.rs created+119
......@@ -0,0 +1,119 @@
1//@ ignore-cross-compile (needs to run doctests)
2
3use run_make_support::rfs::write;
4use run_make_support::{cwd, rustdoc};
5
6fn assert_presence_of_compilation_time_report(
7 content: &str,
8 success: bool,
9 should_contain_compile_time: bool,
10) {
11 let mut cmd = rustdoc();
12 let file = cwd().join("foo.rs");
13
14 write(&file, content);
15 cmd.input(&file).arg("--test").edition("2024").env("RUST_BACKTRACE", "0");
16 let output = if success { cmd.run() } else { cmd.run_fail() };
17
18 assert_eq!(
19 output
20 .stdout_utf8()
21 .split("all doctests ran in ")
22 .last()
23 .is_some_and(|s| s.contains("; merged doctests compilation took")),
24 should_contain_compile_time,
25 );
26}
27
28fn main() {
29 // Checking with only successful merged doctests.
30 assert_presence_of_compilation_time_report(
31 "\
32//! ```
33//! let x = 12;
34//! ```",
35 true,
36 true,
37 );
38 // Checking with only failing merged doctests.
39 assert_presence_of_compilation_time_report(
40 "\
41//! ```
42//! panic!();
43//! ```",
44 false,
45 true,
46 );
47 // Checking with mix of successful doctests.
48 assert_presence_of_compilation_time_report(
49 "\
50//! ```
51//! let x = 12;
52//! ```
53//!
54//! ```compile_fail
55//! let x
56//! ```",
57 true,
58 true,
59 );
60 // Checking with mix of failing doctests.
61 assert_presence_of_compilation_time_report(
62 "\
63//! ```
64//! panic!();
65//! ```
66//!
67//! ```compile_fail
68//! let x
69//! ```",
70 false,
71 true,
72 );
73 // Checking with mix of failing doctests (v2).
74 assert_presence_of_compilation_time_report(
75 "\
76//! ```
77//! let x = 12;
78//! ```
79//!
80//! ```compile_fail
81//! let x = 12;
82//! ```",
83 false,
84 true,
85 );
86 // Checking with mix of failing doctests (v3).
87 assert_presence_of_compilation_time_report(
88 "\
89//! ```
90//! panic!();
91//! ```
92//!
93//! ```compile_fail
94//! let x = 12;
95//! ```",
96 false,
97 true,
98 );
99 // Checking with successful non-merged doctests.
100 assert_presence_of_compilation_time_report(
101 "\
102//! ```compile_fail
103//! let x
104//! ```",
105 true,
106 // If there is no merged doctests, then we should not display compilation time.
107 false,
108 );
109 // Checking with failing non-merged doctests.
110 assert_presence_of_compilation_time_report(
111 "\
112//! ```compile_fail
113//! let x = 12;
114//! ```",
115 false,
116 // If there is no merged doctests, then we should not display compilation time.
117 false,
118 );
119}
tests/run-make/doctests-merge/doctest-2024.stdout+1
......@@ -5,3 +5,4 @@ test doctest.rs - init (line 8) ... ok
55
66test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
77
8all doctests ran in $TIME; merged doctests compilation took $TIME
tests/run-make/doctests-merge/rmake.rs+2
......@@ -20,6 +20,8 @@ fn test_and_compare(input_file: &str, stdout_file: &str, edition: &str, dep: &Pa
2020 .expected_file(stdout_file)
2121 .actual_text("output", output.stdout_utf8())
2222 .normalize(r#"finished in \d+\.\d+s"#, "finished in $$TIME")
23 .normalize(r#"ran in \d+\.\d+s"#, "ran in $$TIME")
24 .normalize(r#"compilation took \d+\.\d+s"#, "compilation took $$TIME")
2325 .run();
2426}
2527
tests/run-make/linker-warning/rmake.rs+1-1
......@@ -61,13 +61,13 @@ fn main() {
6161 diff()
6262 .expected_file("short-error.txt")
6363 .actual_text("(linker error)", out.stderr())
64 .normalize("libpanic_abort", "libpanic_unwind")
6564 .normalize(
6665 regex::escape(
6766 run_make_support::build_root().canonicalize().unwrap().to_str().unwrap(),
6867 ),
6968 "/build-root",
7069 )
70 .normalize("libpanic_abort", "libpanic_unwind")
7171 .normalize(r#""[^"]*\/symbols.o""#, "\"/symbols.o\"")
7272 .normalize(r#""[^"]*\/raw-dylibs""#, "\"/raw-dylibs\"")
7373 .run();
tests/rustdoc-ui/doctest/doctest-output.edition2015.stdout+3-3
......@@ -1,8 +1,8 @@
11
22running 3 tests
3test $DIR/doctest-output.rs - (line 12) ... ok
4test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok
5test $DIR/doctest-output.rs - foo::bar (line 22) ... ok
3test $DIR/doctest-output.rs - (line 14) ... ok
4test $DIR/doctest-output.rs - ExpandedStruct (line 30) ... ok
5test $DIR/doctest-output.rs - foo::bar (line 24) ... ok
66
77test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
88
tests/rustdoc-ui/doctest/doctest-output.edition2024.stdout+4-3
......@@ -1,8 +1,9 @@
11
22running 3 tests
3test $DIR/doctest-output.rs - (line 12) ... ok
4test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok
5test $DIR/doctest-output.rs - foo::bar (line 22) ... ok
3test $DIR/doctest-output.rs - (line 14) ... ok
4test $DIR/doctest-output.rs - ExpandedStruct (line 30) ... ok
5test $DIR/doctest-output.rs - foo::bar (line 24) ... ok
66
77test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
88
9all doctests ran in $TIME; merged doctests compilation took $TIME
tests/rustdoc-ui/doctest/doctest-output.rs+2
......@@ -7,6 +7,8 @@
77//@[edition2024]compile-flags:--test --test-args=--test-threads=1
88//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
99//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
10//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME"
11//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME"
1012//@ check-pass
1113
1214//! ```
tests/rustdoc-ui/doctest/merged-ignore-no_run.rs+2
......@@ -2,6 +2,8 @@
22//@ compile-flags:--test --test-args=--test-threads=1
33//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
44//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
5//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME"
6//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME"
57//@ check-pass
68
79/// ```ignore (test)
tests/rustdoc-ui/doctest/merged-ignore-no_run.stdout+3-2
......@@ -1,7 +1,8 @@
11
22running 2 tests
3test $DIR/merged-ignore-no_run.rs - ignored (line 7) ... ignored
4test $DIR/merged-ignore-no_run.rs - no_run (line 12) - compile ... ok
3test $DIR/merged-ignore-no_run.rs - ignored (line 9) ... ignored
4test $DIR/merged-ignore-no_run.rs - no_run (line 14) - compile ... ok
55
66test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME
77
8all doctests ran in $TIME; merged doctests compilation took $TIME
tests/ui/feature-gates/feature-gate-reborrow-coerce-shared.rs created+3
......@@ -0,0 +1,3 @@
1use std::ops::CoerceShared; //~ ERROR use of unstable library feature `reborrow`
2
3fn main() {}
tests/ui/feature-gates/feature-gate-reborrow-coerce-shared.stderr created+13
......@@ -0,0 +1,13 @@
1error[E0658]: use of unstable library feature `reborrow`
2 --> $DIR/feature-gate-reborrow-coerce-shared.rs:1:5
3 |
4LL | use std::ops::CoerceShared;
5 | ^^^^^^^^^^^^^^^^^^^^^^
6 |
7 = note: see issue #145612 <https://github.com/rust-lang/rust/issues/145612> for more information
8 = help: add `#![feature(reborrow)]` to the crate attributes to enable
9 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
11error: aborting due to 1 previous error
12
13For more information about this error, try `rustc --explain E0658`.
tests/ui/feature-gates/feature-gate-reborrow.rs+1-1
......@@ -1,3 +1,3 @@
1use std::marker::Reborrow; //~ ERROR use of unstable library feature `reborrow`
1use std::ops::Reborrow; //~ ERROR use of unstable library feature `reborrow`
22
33fn main() {}
tests/ui/feature-gates/feature-gate-reborrow.stderr+2-2
......@@ -1,8 +1,8 @@
11error[E0658]: use of unstable library feature `reborrow`
22 --> $DIR/feature-gate-reborrow.rs:1:5
33 |
4LL | use std::marker::Reborrow;
5 | ^^^^^^^^^^^^^^^^^^^^^
4LL | use std::ops::Reborrow;
5 | ^^^^^^^^^^^^^^^^^^
66 |
77 = note: see issue #145612 <https://github.com/rust-lang/rust/issues/145612> for more information
88 = help: add `#![feature(reborrow)]` to the crate attributes to enable
tests/ui/reborrow/custom_mut.rs created+13
......@@ -0,0 +1,13 @@
1#![feature(reborrow)]
2use std::ops::Reborrow;
3
4struct CustomMut<'a, T>(&'a mut T);
5impl<'a, T> Reborrow for CustomMut<'a, T> {}
6
7fn method(a: CustomMut<'_, ()>) {}
8
9fn main() {
10 let a = CustomMut(&mut ());
11 let _ = method(a);
12 let _ = method(a); //~ERROR use of moved value: `a`
13}
tests/ui/reborrow/custom_mut.stderr created+29
......@@ -0,0 +1,29 @@
1error[E0382]: use of moved value: `a`
2 --> $DIR/custom_mut.rs:12:20
3 |
4LL | let a = CustomMut(&mut ());
5 | - move occurs because `a` has type `CustomMut<'_, ()>`, which does not implement the `Copy` trait
6LL | let _ = method(a);
7 | - value moved here
8LL | let _ = method(a);
9 | ^ value used here after move
10 |
11note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
12 --> $DIR/custom_mut.rs:7:14
13 |
14LL | fn method(a: CustomMut<'_, ()>) {}
15 | ------ ^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value
16 | |
17 | in this function
18note: if `CustomMut<'_, ()>` implemented `Clone`, you could clone the value
19 --> $DIR/custom_mut.rs:4:1
20 |
21LL | struct CustomMut<'a, T>(&'a mut T);
22 | ^^^^^^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
23...
24LL | let _ = method(a);
25 | - you could clone this value
26
27error: aborting due to 1 previous error
28
29For more information about this error, try `rustc --explain E0382`.
tests/ui/reborrow/custom_mut_coerce_shared.rs created+28
......@@ -0,0 +1,28 @@
1#![feature(reborrow)]
2use std::ops::{CoerceShared, Reborrow};
3
4struct CustomMut<'a, T>(&'a mut T);
5impl<'a, T> Reborrow for CustomMut<'a, T> {}
6impl<'a, T> CoerceShared for CustomMut<'a, T> {
7 type Target = CustomRef<'a, T>;
8}
9
10struct CustomRef<'a, T>(&'a T);
11
12impl<'a, T> Clone for CustomRef<'a, T> {
13 fn clone(&self) -> Self {
14 Self(self.0)
15 }
16}
17impl<'a, T> Copy for CustomRef<'a, T> {}
18
19fn method(a: CustomRef<'_, ()>) {} //~NOTE function defined here
20
21fn main() {
22 let a = CustomMut(&mut ());
23 method(a);
24 //~^ ERROR mismatched types
25 //~| NOTE expected `CustomRef<'_, ()>`, found `CustomMut<'_, ()>`
26 //~| NOTE arguments to this function are incorrect
27 //~| NOTE expected struct `CustomRef<'_, ()>`
28}
tests/ui/reborrow/custom_mut_coerce_shared.stderr created+19
......@@ -0,0 +1,19 @@
1error[E0308]: mismatched types
2 --> $DIR/custom_mut_coerce_shared.rs:23:12
3 |
4LL | method(a);
5 | ------ ^ expected `CustomRef<'_, ()>`, found `CustomMut<'_, ()>`
6 | |
7 | arguments to this function are incorrect
8 |
9 = note: expected struct `CustomRef<'_, ()>`
10 found struct `CustomMut<'_, ()>`
11note: function defined here
12 --> $DIR/custom_mut_coerce_shared.rs:19:4
13 |
14LL | fn method(a: CustomRef<'_, ()>) {}
15 | ^^^^^^ --------------------
16
17error: aborting due to 1 previous error
18
19For more information about this error, try `rustc --explain E0308`.
tests/ui/reborrow/option_mut.rs created+7
......@@ -0,0 +1,7 @@
1fn method(a: Option<&mut ()>) {}
2
3fn main() {
4 let a = Some(&mut ());
5 let _ = method(a);
6 let _ = method(a); //~ERROR use of moved value: `a`
7}
tests/ui/reborrow/option_mut.stderr created+21
......@@ -0,0 +1,21 @@
1error[E0382]: use of moved value: `a`
2 --> $DIR/option_mut.rs:6:20
3 |
4LL | let a = Some(&mut ());
5 | - move occurs because `a` has type `Option<&mut ()>`, which does not implement the `Copy` trait
6LL | let _ = method(a);
7 | - value moved here
8LL | let _ = method(a);
9 | ^ value used here after move
10 |
11note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
12 --> $DIR/option_mut.rs:1:14
13 |
14LL | fn method(a: Option<&mut ()>) {}
15 | ------ ^^^^^^^^^^^^^^^ this parameter takes ownership of the value
16 | |
17 | in this function
18
19error: aborting due to 1 previous error
20
21For more information about this error, try `rustc --explain E0382`.
tests/ui/reborrow/option_mut_coerce_shared.rs created+11
......@@ -0,0 +1,11 @@
1fn method(a: Option<&()>) {} //~NOTE function defined here
2
3fn main() {
4 let a = Some(&mut ());
5 method(a);
6 //~^ ERROR mismatched types
7 //~| NOTE arguments to this function are incorrect
8 //~| NOTE types differ in mutability
9 //~| NOTE expected enum `Option<&()>`
10 //~| NOTE found enum `Option<&mut ()>`
11}
tests/ui/reborrow/option_mut_coerce_shared.stderr created+23
......@@ -0,0 +1,23 @@
1error[E0308]: mismatched types
2 --> $DIR/option_mut_coerce_shared.rs:5:12
3 |
4LL | method(a);
5 | ------ ^ types differ in mutability
6 | |
7 | arguments to this function are incorrect
8 |
9 = note: expected enum `Option<&()>`
10 found enum `Option<&mut ()>`
11note: function defined here
12 --> $DIR/option_mut_coerce_shared.rs:1:4
13 |
14LL | fn method(a: Option<&()>) {}
15 | ^^^^^^ --------------
16help: try using `.as_deref()` to convert `Option<&mut ()>` to `Option<&()>`
17 |
18LL | method(a.as_deref());
19 | +++++++++++
20
21error: aborting due to 1 previous error
22
23For more information about this error, try `rustc --explain E0308`.
tests/ui/reborrow/pin_mut.rs created+10
......@@ -0,0 +1,10 @@
1use std::pin::Pin;
2
3fn method(a: Pin<&mut ()>) {}
4
5fn main() {
6 let a = &mut ();
7 let a = Pin::new(a);
8 let _ = method(a);
9 let _ = method(a); //~ERROR use of moved value: `a`
10}
tests/ui/reborrow/pin_mut.stderr created+21
......@@ -0,0 +1,21 @@
1error[E0382]: use of moved value: `a`
2 --> $DIR/pin_mut.rs:9:20
3 |
4LL | let a = Pin::new(a);
5 | - move occurs because `a` has type `Pin<&mut ()>`, which does not implement the `Copy` trait
6LL | let _ = method(a);
7 | - value moved here
8LL | let _ = method(a);
9 | ^ value used here after move
10 |
11note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
12 --> $DIR/pin_mut.rs:3:14
13 |
14LL | fn method(a: Pin<&mut ()>) {}
15 | ------ ^^^^^^^^^^^^ this parameter takes ownership of the value
16 | |
17 | in this function
18
19error: aborting due to 1 previous error
20
21For more information about this error, try `rustc --explain E0382`.
tests/ui/reborrow/pin_mut_coerce_shared.rs created+13
......@@ -0,0 +1,13 @@
1use std::pin::Pin;
2
3fn method(a: Pin<&()>) {} //~NOTE function defined here
4
5fn main() {
6 let a = &mut ();
7 let a = Pin::new(a);
8 method(a);
9 //~^ ERROR mismatched types
10 //~| NOTE arguments to this function are incorrect
11 //~| NOTE types differ in mutability
12 //~| NOTE expected struct `Pin<&()>`
13}
tests/ui/reborrow/pin_mut_coerce_shared.stderr created+19
......@@ -0,0 +1,19 @@
1error[E0308]: mismatched types
2 --> $DIR/pin_mut_coerce_shared.rs:8:12
3 |
4LL | method(a);
5 | ------ ^ types differ in mutability
6 | |
7 | arguments to this function are incorrect
8 |
9 = note: expected struct `Pin<&()>`
10 found struct `Pin<&mut ()>`
11note: function defined here
12 --> $DIR/pin_mut_coerce_shared.rs:3:4
13 |
14LL | fn method(a: Pin<&()>) {}
15 | ^^^^^^ -----------
16
17error: aborting due to 1 previous error
18
19For more information about this error, try `rustc --explain E0308`.