| author | bors <bors@rust-lang.org> 2025-09-27 22:30:56 UTC |
| committer | bors <bors@rust-lang.org> 2025-09-27 22:30:56 UTC |
| log | 848e6746fe03dfd703075c5077312b63877d51d6 |
| tree | eba347843510a17e763b7a896a3955759784b546 |
| parent | 4082d6a3f0347c2fc4b8c8d5a6a38ed7248fa161 |
| parent | bd2e18671d4eb0c2cf33965748c270a8ec358557 |
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: rollup55 files changed, 576 insertions(+), 114 deletions(-)
bootstrap.example.toml+3-4| ... | ... | @@ -768,8 +768,7 @@ |
| 768 | 768 | # make this default to false. |
| 769 | 769 | #rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true |
| 770 | 770 | |
| 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. | |
| 773 | 772 | # If set to `true` or `"external"`, a global `lld` binary that has to be in $PATH |
| 774 | 773 | # will be used. |
| 775 | 774 | # If set to `"self-contained"`, rust-lld from the snapshot compiler will be used. |
| ... | ... | @@ -777,7 +776,7 @@ |
| 777 | 776 | # On MSVC, LLD will not be used if we're cross linking. |
| 778 | 777 | # |
| 779 | 778 | # 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 | |
| 781 | 780 | |
| 782 | 781 | # Indicates whether some LLVM tools, like llvm-objdump, will be made available in the |
| 783 | 782 | # sysroot. |
| ... | ... | @@ -950,7 +949,7 @@ |
| 950 | 949 | # Linker to be used to bootstrap Rust code. Note that the |
| 951 | 950 | # default value is platform specific, and if not specified it may also depend on |
| 952 | 951 | # 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. | |
| 954 | 953 | #linker = "cc" (path) |
| 955 | 954 | |
| 956 | 955 | # 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! { |
| 440 | 440 | |
| 441 | 441 | // Reborrowing related lang-items |
| 442 | 442 | Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0); |
| 443 | CoerceShared, sym::coerce_shared, coerce_shared, Target::Trait, GenericRequirement::Exact(0); | |
| 443 | 444 | } |
| 444 | 445 | |
| 445 | 446 | /// 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( |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | std::optional<PGOOptions> PGOOpt; |
| 572 | #if LLVM_VERSION_LT(22, 0) | |
| 572 | 573 | auto FS = vfs::getRealFileSystem(); |
| 574 | #endif | |
| 573 | 575 | if (PGOGenPath) { |
| 574 | 576 | assert(!PGOUsePath && !PGOSampleUsePath); |
| 575 | 577 | PGOOpt = PGOOptions( |
| 578 | #if LLVM_VERSION_GE(22, 0) | |
| 579 | PGOGenPath, "", "", "", PGOOptions::IRInstr, PGOOptions::NoCSAction, | |
| 580 | #else | |
| 576 | 581 | PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction, |
| 582 | #endif | |
| 577 | 583 | PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling); |
| 578 | 584 | } else if (PGOUsePath) { |
| 579 | 585 | assert(!PGOSampleUsePath); |
| 580 | 586 | PGOOpt = PGOOptions( |
| 587 | #if LLVM_VERSION_GE(22, 0) | |
| 588 | PGOUsePath, "", "", "", PGOOptions::IRUse, PGOOptions::NoCSAction, | |
| 589 | #else | |
| 581 | 590 | PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction, |
| 591 | #endif | |
| 582 | 592 | PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling); |
| 583 | 593 | } else if (PGOSampleUsePath) { |
| 584 | 594 | PGOOpt = |
| 595 | #if LLVM_VERSION_GE(22, 0) | |
| 596 | PGOOptions(PGOSampleUsePath, "", "", "", PGOOptions::SampleUse, | |
| 597 | #else | |
| 585 | 598 | PGOOptions(PGOSampleUsePath, "", "", "", FS, PGOOptions::SampleUse, |
| 599 | #endif | |
| 586 | 600 | PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default, |
| 587 | 601 | DebugInfoForProfiling); |
| 588 | 602 | } else if (DebugInfoForProfiling) { |
| 589 | 603 | PGOOpt = PGOOptions( |
| 604 | #if LLVM_VERSION_GE(22, 0) | |
| 605 | "", "", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction, | |
| 606 | #else | |
| 590 | 607 | "", "", "", "", FS, PGOOptions::NoAction, PGOOptions::NoCSAction, |
| 608 | #endif | |
| 591 | 609 | PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling); |
| 592 | 610 | } |
| 593 | 611 |
compiler/rustc_metadata/src/rmeta/decoder.rs+1-1| ... | ... | @@ -1555,7 +1555,7 @@ impl<'a> CrateMetadataRef<'a> { |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | 1557 | #[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> { | |
| 1559 | 1559 | self.def_path_hash_map.def_path_hash_to_def_index(&hash) |
| 1560 | 1560 | } |
| 1561 | 1561 |
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs+2-2| ... | ... | @@ -691,8 +691,8 @@ fn provide_cstore_hooks(providers: &mut Providers) { |
| 691 | 691 | .get(&stable_crate_id) |
| 692 | 692 | .unwrap_or_else(|| bug!("uninterned StableCrateId: {stable_crate_id:?}")); |
| 693 | 693 | 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 }) | |
| 696 | 696 | }; |
| 697 | 697 | |
| 698 | 698 | 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> { |
| 12 | 12 | |
| 13 | 13 | impl DefPathHashMapRef<'_> { |
| 14 | 14 | #[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> { | |
| 16 | 19 | 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()), | |
| 20 | 21 | DefPathHashMapRef::BorrowedFromTcx(_) => { |
| 21 | 22 | panic!("DefPathHashMap::BorrowedFromTcx variant only exists for serialization") |
| 22 | 23 | } |
compiler/rustc_middle/src/hooks/mod.rs+1-1| ... | ... | @@ -77,7 +77,7 @@ declare_hooks! { |
| 77 | 77 | /// session, if it still exists. This is used during incremental compilation to |
| 78 | 78 | /// turn a deserialized `DefPathHash` into its current `DefId`. |
| 79 | 79 | /// 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>; | |
| 81 | 81 | |
| 82 | 82 | /// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we |
| 83 | 83 | /// 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> { |
| 2012 | 2012 | if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) { |
| 2013 | 2013 | Some(self.untracked.definitions.read().local_def_path_hash_to_def_id(hash)?.to_def_id()) |
| 2014 | 2014 | } 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) | |
| 2016 | 2016 | } |
| 2017 | 2017 | } |
| 2018 | 2018 |
compiler/rustc_span/src/symbol.rs+1| ... | ... | @@ -679,6 +679,7 @@ symbols! { |
| 679 | 679 | cmpxchg16b_target_feature, |
| 680 | 680 | cmse_nonsecure_entry, |
| 681 | 681 | coerce_pointee_validated, |
| 682 | coerce_shared, | |
| 682 | 683 | coerce_unsized, |
| 683 | 684 | cold, |
| 684 | 685 | cold_path, |
library/core/src/marker.rs-8| ... | ... | @@ -1341,11 +1341,3 @@ pub macro CoercePointee($item:item) { |
| 1341 | 1341 | pub trait CoercePointeeValidated { |
| 1342 | 1342 | /* compiler built-in */ |
| 1343 | 1343 | } |
| 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")] | |
| 1349 | pub trait Reborrow { | |
| 1350 | // Empty. | |
| 1351 | } |
library/core/src/num/f128.rs+6-6| ... | ... | @@ -33,12 +33,12 @@ pub mod consts { |
| 33 | 33 | |
| 34 | 34 | /// The golden ratio (φ) |
| 35 | 35 | #[unstable(feature = "f128", issue = "116909")] |
| 36 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 36 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 37 | 37 | pub const PHI: f128 = 1.61803398874989484820458683436563811772030917980576286213545_f128; |
| 38 | 38 | |
| 39 | 39 | /// The Euler-Mascheroni constant (γ) |
| 40 | 40 | #[unstable(feature = "f128", issue = "116909")] |
| 41 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 41 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 42 | 42 | pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128; |
| 43 | 43 | |
| 44 | 44 | /// π/2 |
| ... | ... | @@ -67,14 +67,14 @@ pub mod consts { |
| 67 | 67 | |
| 68 | 68 | /// 1/sqrt(π) |
| 69 | 69 | #[unstable(feature = "f128", issue = "116909")] |
| 70 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 70 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 71 | 71 | pub const FRAC_1_SQRT_PI: f128 = |
| 72 | 72 | 0.564189583547756286948079451560772585844050629328998856844086_f128; |
| 73 | 73 | |
| 74 | 74 | /// 1/sqrt(2π) |
| 75 | 75 | #[doc(alias = "FRAC_1_SQRT_TAU")] |
| 76 | 76 | #[unstable(feature = "f128", issue = "116909")] |
| 77 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 77 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 78 | 78 | pub const FRAC_1_SQRT_2PI: f128 = |
| 79 | 79 | 0.398942280401432677939946059934381868475858631164934657665926_f128; |
| 80 | 80 | |
| ... | ... | @@ -98,12 +98,12 @@ pub mod consts { |
| 98 | 98 | |
| 99 | 99 | /// sqrt(3) |
| 100 | 100 | #[unstable(feature = "f128", issue = "116909")] |
| 101 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 101 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 102 | 102 | pub const SQRT_3: f128 = 1.73205080756887729352744634150587236694280525381038062805581_f128; |
| 103 | 103 | |
| 104 | 104 | /// 1/sqrt(3) |
| 105 | 105 | #[unstable(feature = "f128", issue = "116909")] |
| 106 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 106 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 107 | 107 | pub const FRAC_1_SQRT_3: f128 = |
| 108 | 108 | 0.577350269189625764509148780501957455647601751270126876018602_f128; |
| 109 | 109 |
library/core/src/num/f16.rs+6-6| ... | ... | @@ -35,12 +35,12 @@ pub mod consts { |
| 35 | 35 | |
| 36 | 36 | /// The golden ratio (φ) |
| 37 | 37 | #[unstable(feature = "f16", issue = "116909")] |
| 38 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 38 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 39 | 39 | pub const PHI: f16 = 1.618033988749894848204586834365638118_f16; |
| 40 | 40 | |
| 41 | 41 | /// The Euler-Mascheroni constant (γ) |
| 42 | 42 | #[unstable(feature = "f16", issue = "116909")] |
| 43 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 43 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 44 | 44 | pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16; |
| 45 | 45 | |
| 46 | 46 | /// π/2 |
| ... | ... | @@ -69,13 +69,13 @@ pub mod consts { |
| 69 | 69 | |
| 70 | 70 | /// 1/sqrt(π) |
| 71 | 71 | #[unstable(feature = "f16", issue = "116909")] |
| 72 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 72 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 73 | 73 | pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16; |
| 74 | 74 | |
| 75 | 75 | /// 1/sqrt(2π) |
| 76 | 76 | #[doc(alias = "FRAC_1_SQRT_TAU")] |
| 77 | 77 | #[unstable(feature = "f16", issue = "116909")] |
| 78 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 78 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 79 | 79 | pub const FRAC_1_SQRT_2PI: f16 = 0.398942280401432677939946059934381868_f16; |
| 80 | 80 | |
| 81 | 81 | /// 2/π |
| ... | ... | @@ -96,12 +96,12 @@ pub mod consts { |
| 96 | 96 | |
| 97 | 97 | /// sqrt(3) |
| 98 | 98 | #[unstable(feature = "f16", issue = "116909")] |
| 99 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 99 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 100 | 100 | pub const SQRT_3: f16 = 1.732050807568877293527446341505872367_f16; |
| 101 | 101 | |
| 102 | 102 | /// 1/sqrt(3) |
| 103 | 103 | #[unstable(feature = "f16", issue = "116909")] |
| 104 | // Also, #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 104 | // Also, #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 105 | 105 | pub const FRAC_1_SQRT_3: f16 = 0.577350269189625764509148780501957456_f16; |
| 106 | 106 | |
| 107 | 107 | /// Euler's number (e) |
library/core/src/num/f32.rs+6-6| ... | ... | @@ -291,11 +291,11 @@ pub mod consts { |
| 291 | 291 | pub const TAU: f32 = 6.28318530717958647692528676655900577_f32; |
| 292 | 292 | |
| 293 | 293 | /// The golden ratio (φ) |
| 294 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 294 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 295 | 295 | pub const PHI: f32 = 1.618033988749894848204586834365638118_f32; |
| 296 | 296 | |
| 297 | 297 | /// The Euler-Mascheroni constant (γ) |
| 298 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 298 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 299 | 299 | pub const EGAMMA: f32 = 0.577215664901532860606512090082402431_f32; |
| 300 | 300 | |
| 301 | 301 | /// π/2 |
| ... | ... | @@ -323,12 +323,12 @@ pub mod consts { |
| 323 | 323 | pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32; |
| 324 | 324 | |
| 325 | 325 | /// 1/sqrt(π) |
| 326 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 326 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 327 | 327 | pub const FRAC_1_SQRT_PI: f32 = 0.564189583547756286948079451560772586_f32; |
| 328 | 328 | |
| 329 | 329 | /// 1/sqrt(2π) |
| 330 | 330 | #[doc(alias = "FRAC_1_SQRT_TAU")] |
| 331 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 331 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 332 | 332 | pub const FRAC_1_SQRT_2PI: f32 = 0.398942280401432677939946059934381868_f32; |
| 333 | 333 | |
| 334 | 334 | /// 2/π |
| ... | ... | @@ -348,11 +348,11 @@ pub mod consts { |
| 348 | 348 | pub const FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039_f32; |
| 349 | 349 | |
| 350 | 350 | /// sqrt(3) |
| 351 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 351 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 352 | 352 | pub const SQRT_3: f32 = 1.732050807568877293527446341505872367_f32; |
| 353 | 353 | |
| 354 | 354 | /// 1/sqrt(3) |
| 355 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 355 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 356 | 356 | pub const FRAC_1_SQRT_3: f32 = 0.577350269189625764509148780501957456_f32; |
| 357 | 357 | |
| 358 | 358 | /// Euler's number (e) |
library/core/src/num/f64.rs+6-6| ... | ... | @@ -291,11 +291,11 @@ pub mod consts { |
| 291 | 291 | pub const TAU: f64 = 6.28318530717958647692528676655900577_f64; |
| 292 | 292 | |
| 293 | 293 | /// The golden ratio (φ) |
| 294 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 294 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 295 | 295 | pub const PHI: f64 = 1.618033988749894848204586834365638118_f64; |
| 296 | 296 | |
| 297 | 297 | /// The Euler-Mascheroni constant (γ) |
| 298 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 298 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 299 | 299 | pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64; |
| 300 | 300 | |
| 301 | 301 | /// π/2 |
| ... | ... | @@ -323,12 +323,12 @@ pub mod consts { |
| 323 | 323 | pub const FRAC_1_PI: f64 = 0.318309886183790671537767526745028724_f64; |
| 324 | 324 | |
| 325 | 325 | /// 1/sqrt(π) |
| 326 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 326 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 327 | 327 | pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64; |
| 328 | 328 | |
| 329 | 329 | /// 1/sqrt(2π) |
| 330 | 330 | #[doc(alias = "FRAC_1_SQRT_TAU")] |
| 331 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 331 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 332 | 332 | pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64; |
| 333 | 333 | |
| 334 | 334 | /// 2/π |
| ... | ... | @@ -348,11 +348,11 @@ pub mod consts { |
| 348 | 348 | pub const FRAC_1_SQRT_2: f64 = 0.707106781186547524400844362104849039_f64; |
| 349 | 349 | |
| 350 | 350 | /// sqrt(3) |
| 351 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 351 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 352 | 352 | pub const SQRT_3: f64 = 1.732050807568877293527446341505872367_f64; |
| 353 | 353 | |
| 354 | 354 | /// 1/sqrt(3) |
| 355 | #[unstable(feature = "more_float_constants", issue = "103883")] | |
| 355 | #[unstable(feature = "more_float_constants", issue = "146939")] | |
| 356 | 356 | pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64; |
| 357 | 357 | |
| 358 | 358 | /// Euler's number (e) |
library/core/src/ops/mod.rs+3| ... | ... | @@ -149,6 +149,7 @@ mod function; |
| 149 | 149 | mod index; |
| 150 | 150 | mod index_range; |
| 151 | 151 | mod range; |
| 152 | mod reborrow; | |
| 152 | 153 | mod try_trait; |
| 153 | 154 | mod unsize; |
| 154 | 155 | |
| ... | ... | @@ -189,6 +190,8 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; |
| 189 | 190 | pub use self::range::{OneSidedRange, OneSidedRangeBound}; |
| 190 | 191 | #[stable(feature = "rust1", since = "1.0.0")] |
| 191 | 192 | pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; |
| 193 | #[unstable(feature = "reborrow", issue = "145612")] | |
| 194 | pub use self::reborrow::{CoerceShared, Reborrow}; | |
| 192 | 195 | #[unstable(feature = "try_trait_v2_residual", issue = "91285")] |
| 193 | 196 | pub use self::try_trait::Residual; |
| 194 | 197 | #[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")] | |
| 5 | pub 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")] | |
| 13 | pub 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( |
| 1221 | 1221 | // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object |
| 1222 | 1222 | // with direct references to protected symbols, so for now we only use protected symbols if |
| 1223 | 1223 | // linking with LLD is enabled. |
| 1224 | if builder.build.config.lld_mode.is_used() { | |
| 1224 | if builder.build.config.bootstrap_override_lld.is_used() { | |
| 1225 | 1225 | cargo.rustflag("-Zdefault-visibility=protected"); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| ... | ... | @@ -1258,7 +1258,7 @@ pub fn rustc_cargo( |
| 1258 | 1258 | // is already on by default in MSVC optimized builds, which is interpreted as --icf=all: |
| 1259 | 1259 | // https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746 |
| 1260 | 1260 | // 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() { | |
| 1262 | 1262 | cargo.rustflag("-Clink-args=-Wl,--icf=all"); |
| 1263 | 1263 | } |
| 1264 | 1264 |
src/bootstrap/src/core/config/config.rs+15-5| ... | ... | @@ -41,7 +41,7 @@ use crate::core::config::toml::gcc::Gcc; |
| 41 | 41 | use crate::core::config::toml::install::Install; |
| 42 | 42 | use crate::core::config::toml::llvm::Llvm; |
| 43 | 43 | use 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, | |
| 45 | 45 | default_lld_opt_in_targets, parse_codegen_backends, |
| 46 | 46 | }; |
| 47 | 47 | use crate::core::config::toml::target::Target; |
| ... | ... | @@ -174,7 +174,7 @@ pub struct Config { |
| 174 | 174 | pub llvm_from_ci: bool, |
| 175 | 175 | pub llvm_build_config: HashMap<String, String>, |
| 176 | 176 | |
| 177 | pub lld_mode: LldMode, | |
| 177 | pub bootstrap_override_lld: BootstrapOverrideLld, | |
| 178 | 178 | pub lld_enabled: bool, |
| 179 | 179 | pub llvm_tools_enabled: bool, |
| 180 | 180 | pub llvm_bitcode_linker_enabled: bool, |
| ... | ... | @@ -567,7 +567,8 @@ impl Config { |
| 567 | 567 | frame_pointers: rust_frame_pointers, |
| 568 | 568 | stack_protector: rust_stack_protector, |
| 569 | 569 | 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, | |
| 571 | 572 | std_features: rust_std_features, |
| 572 | 573 | break_on_ice: rust_break_on_ice, |
| 573 | 574 | } = toml.rust.unwrap_or_default(); |
| ... | ... | @@ -615,6 +616,15 @@ impl Config { |
| 615 | 616 | |
| 616 | 617 | let Gcc { download_ci_gcc: gcc_download_ci_gcc } = toml.gcc.unwrap_or_default(); |
| 617 | 618 | |
| 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 | ||
| 618 | 628 | if rust_optimize.as_ref().is_some_and(|v| matches!(v, RustOptimize::Bool(false))) { |
| 619 | 629 | eprintln!( |
| 620 | 630 | "WARNING: setting `optimize` to `false` is known to cause errors and \ |
| ... | ... | @@ -960,7 +970,7 @@ impl Config { |
| 960 | 970 | |
| 961 | 971 | let initial_rustfmt = build_rustfmt.or_else(|| maybe_download_rustfmt(&dwn_ctx, &out)); |
| 962 | 972 | |
| 963 | if matches!(rust_lld_mode.unwrap_or_default(), LldMode::SelfContained) | |
| 973 | if matches!(bootstrap_override_lld, BootstrapOverrideLld::SelfContained) | |
| 964 | 974 | && !lld_enabled |
| 965 | 975 | && flags_stage.unwrap_or(0) > 0 |
| 966 | 976 | { |
| ... | ... | @@ -1172,6 +1182,7 @@ impl Config { |
| 1172 | 1182 | backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false), |
| 1173 | 1183 | bindir: install_bindir.map(PathBuf::from).unwrap_or("bin".into()), |
| 1174 | 1184 | bootstrap_cache_path: build_bootstrap_cache_path, |
| 1185 | bootstrap_override_lld, | |
| 1175 | 1186 | bypass_bootstrap_lock: flags_bypass_bootstrap_lock, |
| 1176 | 1187 | cargo_info, |
| 1177 | 1188 | cargo_native_static: build_cargo_native_static.unwrap_or(false), |
| ... | ... | @@ -1238,7 +1249,6 @@ impl Config { |
| 1238 | 1249 | libdir: install_libdir.map(PathBuf::from), |
| 1239 | 1250 | library_docs_private_items: build_library_docs_private_items.unwrap_or(false), |
| 1240 | 1251 | lld_enabled, |
| 1241 | lld_mode: rust_lld_mode.unwrap_or_default(), | |
| 1242 | 1252 | lldb: build_lldb.map(PathBuf::from), |
| 1243 | 1253 | llvm_allow_old_toolchain: llvm_allow_old_toolchain.unwrap_or(false), |
| 1244 | 1254 | llvm_assertions, |
src/bootstrap/src/core/config/mod.rs+1-1| ... | ... | @@ -37,7 +37,7 @@ use serde_derive::Deserialize; |
| 37 | 37 | pub use target_selection::TargetSelection; |
| 38 | 38 | pub use toml::BUILDER_CONFIG_FILENAME; |
| 39 | 39 | pub use toml::change_id::ChangeId; |
| 40 | pub use toml::rust::LldMode; | |
| 40 | pub use toml::rust::BootstrapOverrideLld; | |
| 41 | 41 | pub use toml::target::Target; |
| 42 | 42 | |
| 43 | 43 | use 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}; |
| 17 | 17 | use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS; |
| 18 | 18 | use crate::core::build_steps::{llvm, test}; |
| 19 | 19 | use crate::core::config::toml::TomlConfig; |
| 20 | use crate::core::config::{CompilerBuiltins, LldMode, StringOrBool, Target, TargetSelection}; | |
| 20 | use crate::core::config::{ | |
| 21 | BootstrapOverrideLld, CompilerBuiltins, StringOrBool, Target, TargetSelection, | |
| 22 | }; | |
| 21 | 23 | use crate::utils::tests::TestCtx; |
| 22 | 24 | use crate::utils::tests::git::git_test; |
| 23 | 25 | |
| ... | ... | @@ -222,11 +224,33 @@ fn verify_file_integrity() { |
| 222 | 224 | |
| 223 | 225 | #[test] |
| 224 | 226 | fn 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 | )); | |
| 230 | 254 | } |
| 231 | 255 | |
| 232 | 256 | #[test] |
src/bootstrap/src/core/config/toml/rust.rs+31-18| ... | ... | @@ -45,7 +45,9 @@ define_config! { |
| 45 | 45 | codegen_backends: Option<Vec<String>> = "codegen-backends", |
| 46 | 46 | llvm_bitcode_linker: Option<bool> = "llvm-bitcode-linker", |
| 47 | 47 | 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", | |
| 49 | 51 | llvm_tools: Option<bool> = "llvm-tools", |
| 50 | 52 | deny_warnings: Option<bool> = "deny-warnings", |
| 51 | 53 | backtrace_on_ice: Option<bool> = "backtrace-on-ice", |
| ... | ... | @@ -70,22 +72,33 @@ define_config! { |
| 70 | 72 | } |
| 71 | 73 | } |
| 72 | 74 | |
| 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 | |
| 75 | 88 | /// - External: use an external `lld` binary |
| 76 | 89 | /// |
| 77 | 90 | /// It is configured depending on the target: |
| 78 | 91 | /// 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` | |
| 81 | 94 | /// 2) MSVC |
| 82 | 95 | /// - Self-contained: `-Clinker=<path to rust-lld>` |
| 83 | 96 | /// - External: `-Clinker=lld` |
| 84 | 97 | #[derive(Copy, Clone, Default, Debug, PartialEq)] |
| 85 | pub enum LldMode { | |
| 86 | /// Do not use LLD | |
| 98 | pub enum BootstrapOverrideLld { | |
| 99 | /// Do not override the linker LLD | |
| 87 | 100 | #[default] |
| 88 | Unused, | |
| 101 | None, | |
| 89 | 102 | /// Use `rust-lld` from the compiler's sysroot |
| 90 | 103 | SelfContained, |
| 91 | 104 | /// Use an externally provided `lld` binary. |
| ... | ... | @@ -94,16 +107,16 @@ pub enum LldMode { |
| 94 | 107 | External, |
| 95 | 108 | } |
| 96 | 109 | |
| 97 | impl LldMode { | |
| 110 | impl BootstrapOverrideLld { | |
| 98 | 111 | pub fn is_used(&self) -> bool { |
| 99 | 112 | match self { |
| 100 | LldMode::SelfContained | LldMode::External => true, | |
| 101 | LldMode::Unused => false, | |
| 113 | BootstrapOverrideLld::SelfContained | BootstrapOverrideLld::External => true, | |
| 114 | BootstrapOverrideLld::None => false, | |
| 102 | 115 | } |
| 103 | 116 | } |
| 104 | 117 | } |
| 105 | 118 | |
| 106 | impl<'de> Deserialize<'de> for LldMode { | |
| 119 | impl<'de> Deserialize<'de> for BootstrapOverrideLld { | |
| 107 | 120 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
| 108 | 121 | where |
| 109 | 122 | D: Deserializer<'de>, |
| ... | ... | @@ -111,7 +124,7 @@ impl<'de> Deserialize<'de> for LldMode { |
| 111 | 124 | struct LldModeVisitor; |
| 112 | 125 | |
| 113 | 126 | impl serde::de::Visitor<'_> for LldModeVisitor { |
| 114 | type Value = LldMode; | |
| 127 | type Value = BootstrapOverrideLld; | |
| 115 | 128 | |
| 116 | 129 | fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 117 | 130 | formatter.write_str("one of true, 'self-contained' or 'external'") |
| ... | ... | @@ -121,7 +134,7 @@ impl<'de> Deserialize<'de> for LldMode { |
| 121 | 134 | where |
| 122 | 135 | E: serde::de::Error, |
| 123 | 136 | { |
| 124 | Ok(if v { LldMode::External } else { LldMode::Unused }) | |
| 137 | Ok(if v { BootstrapOverrideLld::External } else { BootstrapOverrideLld::None }) | |
| 125 | 138 | } |
| 126 | 139 | |
| 127 | 140 | fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> |
| ... | ... | @@ -129,8 +142,8 @@ impl<'de> Deserialize<'de> for LldMode { |
| 129 | 142 | E: serde::de::Error, |
| 130 | 143 | { |
| 131 | 144 | match v { |
| 132 | "external" => Ok(LldMode::External), | |
| 133 | "self-contained" => Ok(LldMode::SelfContained), | |
| 145 | "external" => Ok(BootstrapOverrideLld::External), | |
| 146 | "self-contained" => Ok(BootstrapOverrideLld::SelfContained), | |
| 134 | 147 | _ => Err(E::custom(format!("unknown mode {v}"))), |
| 135 | 148 | } |
| 136 | 149 | } |
| ... | ... | @@ -311,7 +324,6 @@ pub fn check_incompatible_options_for_ci_rustc( |
| 311 | 324 | lto, |
| 312 | 325 | stack_protector, |
| 313 | 326 | strip, |
| 314 | lld_mode, | |
| 315 | 327 | jemalloc, |
| 316 | 328 | rpath, |
| 317 | 329 | channel, |
| ... | ... | @@ -359,6 +371,8 @@ pub fn check_incompatible_options_for_ci_rustc( |
| 359 | 371 | frame_pointers: _, |
| 360 | 372 | break_on_ice: _, |
| 361 | 373 | parallel_frontend_threads: _, |
| 374 | bootstrap_override_lld: _, | |
| 375 | bootstrap_override_lld_legacy: _, | |
| 362 | 376 | } = ci_rust_config; |
| 363 | 377 | |
| 364 | 378 | // There are two kinds of checks for CI rustc incompatible options: |
| ... | ... | @@ -374,7 +388,6 @@ pub fn check_incompatible_options_for_ci_rustc( |
| 374 | 388 | err!(current_rust_config.debuginfo_level_rustc, debuginfo_level_rustc, "rust"); |
| 375 | 389 | err!(current_rust_config.rpath, rpath, "rust"); |
| 376 | 390 | err!(current_rust_config.strip, strip, "rust"); |
| 377 | err!(current_rust_config.lld_mode, lld_mode, "rust"); | |
| 378 | 391 | err!(current_rust_config.llvm_tools, llvm_tools, "rust"); |
| 379 | 392 | err!(current_rust_config.llvm_bitcode_linker, llvm_bitcode_linker, "rust"); |
| 380 | 393 | err!(current_rust_config.jemalloc, jemalloc, "rust"); |
src/bootstrap/src/lib.rs+6-6| ... | ... | @@ -35,7 +35,7 @@ use utils::exec::ExecutionContext; |
| 35 | 35 | |
| 36 | 36 | use crate::core::builder; |
| 37 | 37 | use crate::core::builder::Kind; |
| 38 | use crate::core::config::{DryRun, LldMode, LlvmLibunwind, TargetSelection, flags}; | |
| 38 | use crate::core::config::{BootstrapOverrideLld, DryRun, LlvmLibunwind, TargetSelection, flags}; | |
| 39 | 39 | use crate::utils::exec::{BootstrapCommand, command}; |
| 40 | 40 | use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, split_debuginfo}; |
| 41 | 41 | |
| ... | ... | @@ -1358,14 +1358,14 @@ impl Build { |
| 1358 | 1358 | && !target.is_msvc() |
| 1359 | 1359 | { |
| 1360 | 1360 | Some(self.cc(target)) |
| 1361 | } else if self.config.lld_mode.is_used() | |
| 1361 | } else if self.config.bootstrap_override_lld.is_used() | |
| 1362 | 1362 | && self.is_lld_direct_linker(target) |
| 1363 | 1363 | && self.host_target == target |
| 1364 | 1364 | { |
| 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, | |
| 1369 | 1369 | } |
| 1370 | 1370 | } else { |
| 1371 | 1371 | None |
src/bootstrap/src/utils/change_tracker.rs+5| ... | ... | @@ -556,4 +556,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ |
| 556 | 556 | severity: ChangeSeverity::Info, |
| 557 | 557 | summary: "New option `build.windows-rc` that will override which resource compiler on Windows will be used to compile Rust.", |
| 558 | 558 | }, |
| 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 | }, | |
| 559 | 564 | ]; |
src/bootstrap/src/utils/helpers.rs+18-10| ... | ... | @@ -12,7 +12,7 @@ use std::{env, fs, io, panic, str}; |
| 12 | 12 | |
| 13 | 13 | use object::read::archive::ArchiveFile; |
| 14 | 14 | |
| 15 | use crate::LldMode; | |
| 15 | use crate::BootstrapOverrideLld; | |
| 16 | 16 | use crate::core::builder::Builder; |
| 17 | 17 | use crate::core::config::{Config, TargetSelection}; |
| 18 | 18 | use crate::utils::exec::{BootstrapCommand, command}; |
| ... | ... | @@ -357,15 +357,19 @@ pub fn get_clang_cl_resource_dir(builder: &Builder<'_>, clang_cl_path: &str) -> |
| 357 | 357 | /// Returns a flag that configures LLD to use only a single thread. |
| 358 | 358 | /// If we use an external LLD, we need to find out which version is it to know which flag should we |
| 359 | 359 | /// pass to it (LLD older than version 10 had a different flag). |
| 360 | fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: bool) -> &'static str { | |
| 360 | fn lld_flag_no_threads( | |
| 361 | builder: &Builder<'_>, | |
| 362 | bootstrap_override_lld: BootstrapOverrideLld, | |
| 363 | is_windows: bool, | |
| 364 | ) -> &'static str { | |
| 361 | 365 | static LLD_NO_THREADS: OnceLock<(&'static str, &'static str)> = OnceLock::new(); |
| 362 | 366 | |
| 363 | 367 | let new_flags = ("/threads:1", "--threads=1"); |
| 364 | 368 | let old_flags = ("/no-threads", "--no-threads"); |
| 365 | 369 | |
| 366 | 370 | 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 => { | |
| 369 | 373 | let mut cmd = command("lld"); |
| 370 | 374 | cmd.arg("-flavor").arg("ld").arg("--version"); |
| 371 | 375 | let out = cmd.run_capture_stdout(builder).stdout(); |
| ... | ... | @@ -422,24 +426,28 @@ pub fn linker_flags( |
| 422 | 426 | lld_threads: LldThreads, |
| 423 | 427 | ) -> Vec<String> { |
| 424 | 428 | 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 => { | |
| 428 | 432 | args.push("-Clinker-features=+lld".to_string()); |
| 429 | 433 | args.push("-Zunstable-options".to_string()); |
| 430 | 434 | } |
| 431 | LldMode::SelfContained => { | |
| 435 | BootstrapOverrideLld::SelfContained => { | |
| 432 | 436 | args.push("-Clinker-features=+lld".to_string()); |
| 433 | 437 | args.push("-Clink-self-contained=+linker".to_string()); |
| 434 | 438 | args.push("-Zunstable-options".to_string()); |
| 435 | 439 | } |
| 436 | LldMode::Unused => unreachable!(), | |
| 440 | BootstrapOverrideLld::None => unreachable!(), | |
| 437 | 441 | }; |
| 438 | 442 | |
| 439 | 443 | if matches!(lld_threads, LldThreads::No) { |
| 440 | 444 | args.push(format!( |
| 441 | 445 | "-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 | ) | |
| 443 | 451 | )); |
| 444 | 452 | } |
| 445 | 453 | } |
src/ci/docker/host-aarch64/dist-aarch64-linux/Dockerfile+1-1| ... | ... | @@ -91,7 +91,7 @@ ENV RUST_CONFIGURE_ARGS \ |
| 91 | 91 | --set llvm.ninja=false \ |
| 92 | 92 | --set rust.debug-assertions=false \ |
| 93 | 93 | --set rust.jemalloc \ |
| 94 | --set rust.use-lld=true \ | |
| 94 | --set rust.bootstrap-override-lld=true \ | |
| 95 | 95 | --set rust.lto=thin \ |
| 96 | 96 | --set rust.codegen-units=1 |
| 97 | 97 |
src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile+1-1| ... | ... | @@ -92,7 +92,7 @@ ENV RUST_CONFIGURE_ARGS \ |
| 92 | 92 | --set llvm.ninja=false \ |
| 93 | 93 | --set llvm.libzstd=true \ |
| 94 | 94 | --set rust.jemalloc \ |
| 95 | --set rust.use-lld=true \ | |
| 95 | --set rust.bootstrap-override-lld=true \ | |
| 96 | 96 | --set rust.lto=thin \ |
| 97 | 97 | --set rust.codegen-units=1 |
| 98 | 98 |
src/librustdoc/doctest.rs+7-3| ... | ... | @@ -404,11 +404,15 @@ pub(crate) fn run_tests( |
| 404 | 404 | std::mem::drop(temp_dir.take()); |
| 405 | 405 | times.display_times(); |
| 406 | 406 | }); |
| 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(); | |
| 407 | 412 | } |
| 413 | // We ensure temp dir destructor is called. | |
| 414 | std::mem::drop(temp_dir); | |
| 408 | 415 | if nb_errors != 0 { |
| 409 | // We ensure temp dir destructor is called. | |
| 410 | std::mem::drop(temp_dir); | |
| 411 | times.display_times(); | |
| 412 | 416 | std::process::exit(test::ERROR_EXIT_CODE); |
| 413 | 417 | } |
| 414 | 418 | } |
tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs+5-2| ... | ... | @@ -1,4 +1,7 @@ |
| 1 | 1 | //@ compile-flags: -Copt-level=3 |
| 2 | //@ revisions: new old | |
| 3 | //@ [old] max-llvm-major-version: 21 | |
| 4 | //@ [new] min-llvm-version: 22 | |
| 2 | 5 | |
| 3 | 6 | #![crate_type = "lib"] |
| 4 | 7 | |
| ... | ... | @@ -22,8 +25,8 @@ pub unsafe fn update(s: *mut State) { |
| 22 | 25 | // CHECK-NOT: memcpy |
| 23 | 26 | // CHECK-NOT: 75{{3|4}} |
| 24 | 27 | |
| 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 | |
| 27 | 30 | |
| 28 | 31 | // CHECK-NOT: load |
| 29 | 32 | // CHECK-NOT: store |
tests/codegen-llvm/vec_pop_push_noop.rs+4-1| ... | ... | @@ -1,4 +1,7 @@ |
| 1 | 1 | //@ compile-flags: -Copt-level=3 |
| 2 | //@ revisions: new old | |
| 3 | //@ [old] max-llvm-major-version: 21 | |
| 4 | //@ [new] min-llvm-version: 22 | |
| 2 | 5 | |
| 3 | 6 | #![crate_type = "lib"] |
| 4 | 7 | |
| ... | ... | @@ -7,7 +10,7 @@ |
| 7 | 10 | pub fn noop(v: &mut Vec<u8>) { |
| 8 | 11 | // CHECK-NOT: grow_one |
| 9 | 12 | // CHECK-NOT: call |
| 10 | // CHECK: tail call void @llvm.assume | |
| 13 | // old: tail call void @llvm.assume | |
| 11 | 14 | // CHECK-NOT: grow_one |
| 12 | 15 | // CHECK-NOT: call |
| 13 | 16 | // CHECK: {{ret|[}]}} |
tests/codegen-llvm/vecdeque_pop_push.rs+4-1| ... | ... | @@ -1,4 +1,7 @@ |
| 1 | 1 | //@ compile-flags: -Copt-level=3 |
| 2 | //@ revisions: new old | |
| 3 | //@ [old] max-llvm-major-version: 21 | |
| 4 | //@ [new] min-llvm-version: 22 | |
| 2 | 5 | |
| 3 | 6 | #![crate_type = "lib"] |
| 4 | 7 | |
| ... | ... | @@ -8,7 +11,7 @@ use std::collections::VecDeque; |
| 8 | 11 | // CHECK-LABEL: @noop_back( |
| 9 | 12 | pub fn noop_back(v: &mut VecDeque<u8>) { |
| 10 | 13 | // CHECK-NOT: grow |
| 11 | // CHECK: tail call void @llvm.assume | |
| 14 | // old: tail call void @llvm.assume | |
| 12 | 15 | // CHECK-NOT: grow |
| 13 | 16 | // CHECK: ret |
| 14 | 17 | 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 | ||
| 3 | use run_make_support::rfs::write; | |
| 4 | use run_make_support::{cwd, rustdoc}; | |
| 5 | ||
| 6 | fn 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 | ||
| 28 | fn 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 |
| 5 | 5 | |
| 6 | 6 | test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME |
| 7 | 7 | |
| 8 | all 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 |
| 20 | 20 | .expected_file(stdout_file) |
| 21 | 21 | .actual_text("output", output.stdout_utf8()) |
| 22 | 22 | .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") | |
| 23 | 25 | .run(); |
| 24 | 26 | } |
| 25 | 27 |
tests/run-make/linker-warning/rmake.rs+1-1| ... | ... | @@ -61,13 +61,13 @@ fn main() { |
| 61 | 61 | diff() |
| 62 | 62 | .expected_file("short-error.txt") |
| 63 | 63 | .actual_text("(linker error)", out.stderr()) |
| 64 | .normalize("libpanic_abort", "libpanic_unwind") | |
| 65 | 64 | .normalize( |
| 66 | 65 | regex::escape( |
| 67 | 66 | run_make_support::build_root().canonicalize().unwrap().to_str().unwrap(), |
| 68 | 67 | ), |
| 69 | 68 | "/build-root", |
| 70 | 69 | ) |
| 70 | .normalize("libpanic_abort", "libpanic_unwind") | |
| 71 | 71 | .normalize(r#""[^"]*\/symbols.o""#, "\"/symbols.o\"") |
| 72 | 72 | .normalize(r#""[^"]*\/raw-dylibs""#, "\"/raw-dylibs\"") |
| 73 | 73 | .run(); |
tests/rustdoc-ui/doctest/doctest-output.edition2015.stdout+3-3| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | |
| 2 | 2 | running 3 tests |
| 3 | test $DIR/doctest-output.rs - (line 12) ... ok | |
| 4 | test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok | |
| 5 | test $DIR/doctest-output.rs - foo::bar (line 22) ... ok | |
| 3 | test $DIR/doctest-output.rs - (line 14) ... ok | |
| 4 | test $DIR/doctest-output.rs - ExpandedStruct (line 30) ... ok | |
| 5 | test $DIR/doctest-output.rs - foo::bar (line 24) ... ok | |
| 6 | 6 | |
| 7 | 7 | test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME |
| 8 | 8 |
tests/rustdoc-ui/doctest/doctest-output.edition2024.stdout+4-3| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | |
| 2 | 2 | running 3 tests |
| 3 | test $DIR/doctest-output.rs - (line 12) ... ok | |
| 4 | test $DIR/doctest-output.rs - ExpandedStruct (line 28) ... ok | |
| 5 | test $DIR/doctest-output.rs - foo::bar (line 22) ... ok | |
| 3 | test $DIR/doctest-output.rs - (line 14) ... ok | |
| 4 | test $DIR/doctest-output.rs - ExpandedStruct (line 30) ... ok | |
| 5 | test $DIR/doctest-output.rs - foo::bar (line 24) ... ok | |
| 6 | 6 | |
| 7 | 7 | test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME |
| 8 | 8 | |
| 9 | all doctests ran in $TIME; merged doctests compilation took $TIME |
tests/rustdoc-ui/doctest/doctest-output.rs+2| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | //@[edition2024]compile-flags:--test --test-args=--test-threads=1 |
| 8 | 8 | //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" |
| 9 | 9 | //@ 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" | |
| 10 | 12 | //@ check-pass |
| 11 | 13 | |
| 12 | 14 | //! ``` |
tests/rustdoc-ui/doctest/merged-ignore-no_run.rs+2| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | //@ compile-flags:--test --test-args=--test-threads=1 |
| 3 | 3 | //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" |
| 4 | 4 | //@ 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" | |
| 5 | 7 | //@ check-pass |
| 6 | 8 | |
| 7 | 9 | /// ```ignore (test) |
tests/rustdoc-ui/doctest/merged-ignore-no_run.stdout+3-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | |
| 2 | 2 | running 2 tests |
| 3 | test $DIR/merged-ignore-no_run.rs - ignored (line 7) ... ignored | |
| 4 | test $DIR/merged-ignore-no_run.rs - no_run (line 12) - compile ... ok | |
| 3 | test $DIR/merged-ignore-no_run.rs - ignored (line 9) ... ignored | |
| 4 | test $DIR/merged-ignore-no_run.rs - no_run (line 14) - compile ... ok | |
| 5 | 5 | |
| 6 | 6 | test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME |
| 7 | 7 | |
| 8 | all 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 @@ |
| 1 | use std::ops::CoerceShared; //~ ERROR use of unstable library feature `reborrow` | |
| 2 | ||
| 3 | fn main() {} |
tests/ui/feature-gates/feature-gate-reborrow-coerce-shared.stderr created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | error[E0658]: use of unstable library feature `reborrow` | |
| 2 | --> $DIR/feature-gate-reborrow-coerce-shared.rs:1:5 | |
| 3 | | | |
| 4 | LL | 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 | ||
| 11 | error: aborting due to 1 previous error | |
| 12 | ||
| 13 | For more information about this error, try `rustc --explain E0658`. |
tests/ui/feature-gates/feature-gate-reborrow.rs+1-1| ... | ... | @@ -1,3 +1,3 @@ |
| 1 | use std::marker::Reborrow; //~ ERROR use of unstable library feature `reborrow` | |
| 1 | use std::ops::Reborrow; //~ ERROR use of unstable library feature `reborrow` | |
| 2 | 2 | |
| 3 | 3 | fn main() {} |
tests/ui/feature-gates/feature-gate-reborrow.stderr+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | error[E0658]: use of unstable library feature `reborrow` |
| 2 | 2 | --> $DIR/feature-gate-reborrow.rs:1:5 |
| 3 | 3 | | |
| 4 | LL | use std::marker::Reborrow; | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | LL | use std::ops::Reborrow; | |
| 5 | | ^^^^^^^^^^^^^^^^^^ | |
| 6 | 6 | | |
| 7 | 7 | = note: see issue #145612 <https://github.com/rust-lang/rust/issues/145612> for more information |
| 8 | 8 | = 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)] | |
| 2 | use std::ops::Reborrow; | |
| 3 | ||
| 4 | struct CustomMut<'a, T>(&'a mut T); | |
| 5 | impl<'a, T> Reborrow for CustomMut<'a, T> {} | |
| 6 | ||
| 7 | fn method(a: CustomMut<'_, ()>) {} | |
| 8 | ||
| 9 | fn 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 @@ |
| 1 | error[E0382]: use of moved value: `a` | |
| 2 | --> $DIR/custom_mut.rs:12:20 | |
| 3 | | | |
| 4 | LL | let a = CustomMut(&mut ()); | |
| 5 | | - move occurs because `a` has type `CustomMut<'_, ()>`, which does not implement the `Copy` trait | |
| 6 | LL | let _ = method(a); | |
| 7 | | - value moved here | |
| 8 | LL | let _ = method(a); | |
| 9 | | ^ value used here after move | |
| 10 | | | |
| 11 | note: 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 | | | |
| 14 | LL | fn method(a: CustomMut<'_, ()>) {} | |
| 15 | | ------ ^^^^^^^^^^^^^^^^^ this parameter takes ownership of the value | |
| 16 | | | | |
| 17 | | in this function | |
| 18 | note: if `CustomMut<'_, ()>` implemented `Clone`, you could clone the value | |
| 19 | --> $DIR/custom_mut.rs:4:1 | |
| 20 | | | |
| 21 | LL | struct CustomMut<'a, T>(&'a mut T); | |
| 22 | | ^^^^^^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type | |
| 23 | ... | |
| 24 | LL | let _ = method(a); | |
| 25 | | - you could clone this value | |
| 26 | ||
| 27 | error: aborting due to 1 previous error | |
| 28 | ||
| 29 | For 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)] | |
| 2 | use std::ops::{CoerceShared, Reborrow}; | |
| 3 | ||
| 4 | struct CustomMut<'a, T>(&'a mut T); | |
| 5 | impl<'a, T> Reborrow for CustomMut<'a, T> {} | |
| 6 | impl<'a, T> CoerceShared for CustomMut<'a, T> { | |
| 7 | type Target = CustomRef<'a, T>; | |
| 8 | } | |
| 9 | ||
| 10 | struct CustomRef<'a, T>(&'a T); | |
| 11 | ||
| 12 | impl<'a, T> Clone for CustomRef<'a, T> { | |
| 13 | fn clone(&self) -> Self { | |
| 14 | Self(self.0) | |
| 15 | } | |
| 16 | } | |
| 17 | impl<'a, T> Copy for CustomRef<'a, T> {} | |
| 18 | ||
| 19 | fn method(a: CustomRef<'_, ()>) {} //~NOTE function defined here | |
| 20 | ||
| 21 | fn 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 @@ |
| 1 | error[E0308]: mismatched types | |
| 2 | --> $DIR/custom_mut_coerce_shared.rs:23:12 | |
| 3 | | | |
| 4 | LL | 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<'_, ()>` | |
| 11 | note: function defined here | |
| 12 | --> $DIR/custom_mut_coerce_shared.rs:19:4 | |
| 13 | | | |
| 14 | LL | fn method(a: CustomRef<'_, ()>) {} | |
| 15 | | ^^^^^^ -------------------- | |
| 16 | ||
| 17 | error: aborting due to 1 previous error | |
| 18 | ||
| 19 | For more information about this error, try `rustc --explain E0308`. |
tests/ui/reborrow/option_mut.rs created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | fn method(a: Option<&mut ()>) {} | |
| 2 | ||
| 3 | fn 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 @@ |
| 1 | error[E0382]: use of moved value: `a` | |
| 2 | --> $DIR/option_mut.rs:6:20 | |
| 3 | | | |
| 4 | LL | let a = Some(&mut ()); | |
| 5 | | - move occurs because `a` has type `Option<&mut ()>`, which does not implement the `Copy` trait | |
| 6 | LL | let _ = method(a); | |
| 7 | | - value moved here | |
| 8 | LL | let _ = method(a); | |
| 9 | | ^ value used here after move | |
| 10 | | | |
| 11 | note: 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 | | | |
| 14 | LL | fn method(a: Option<&mut ()>) {} | |
| 15 | | ------ ^^^^^^^^^^^^^^^ this parameter takes ownership of the value | |
| 16 | | | | |
| 17 | | in this function | |
| 18 | ||
| 19 | error: aborting due to 1 previous error | |
| 20 | ||
| 21 | For more information about this error, try `rustc --explain E0382`. |
tests/ui/reborrow/option_mut_coerce_shared.rs created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | fn method(a: Option<&()>) {} //~NOTE function defined here | |
| 2 | ||
| 3 | fn 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 @@ |
| 1 | error[E0308]: mismatched types | |
| 2 | --> $DIR/option_mut_coerce_shared.rs:5:12 | |
| 3 | | | |
| 4 | LL | 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 ()>` | |
| 11 | note: function defined here | |
| 12 | --> $DIR/option_mut_coerce_shared.rs:1:4 | |
| 13 | | | |
| 14 | LL | fn method(a: Option<&()>) {} | |
| 15 | | ^^^^^^ -------------- | |
| 16 | help: try using `.as_deref()` to convert `Option<&mut ()>` to `Option<&()>` | |
| 17 | | | |
| 18 | LL | method(a.as_deref()); | |
| 19 | | +++++++++++ | |
| 20 | ||
| 21 | error: aborting due to 1 previous error | |
| 22 | ||
| 23 | For more information about this error, try `rustc --explain E0308`. |
tests/ui/reborrow/pin_mut.rs created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | use std::pin::Pin; | |
| 2 | ||
| 3 | fn method(a: Pin<&mut ()>) {} | |
| 4 | ||
| 5 | fn 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 @@ |
| 1 | error[E0382]: use of moved value: `a` | |
| 2 | --> $DIR/pin_mut.rs:9:20 | |
| 3 | | | |
| 4 | LL | let a = Pin::new(a); | |
| 5 | | - move occurs because `a` has type `Pin<&mut ()>`, which does not implement the `Copy` trait | |
| 6 | LL | let _ = method(a); | |
| 7 | | - value moved here | |
| 8 | LL | let _ = method(a); | |
| 9 | | ^ value used here after move | |
| 10 | | | |
| 11 | note: 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 | | | |
| 14 | LL | fn method(a: Pin<&mut ()>) {} | |
| 15 | | ------ ^^^^^^^^^^^^ this parameter takes ownership of the value | |
| 16 | | | | |
| 17 | | in this function | |
| 18 | ||
| 19 | error: aborting due to 1 previous error | |
| 20 | ||
| 21 | For more information about this error, try `rustc --explain E0382`. |
tests/ui/reborrow/pin_mut_coerce_shared.rs created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | use std::pin::Pin; | |
| 2 | ||
| 3 | fn method(a: Pin<&()>) {} //~NOTE function defined here | |
| 4 | ||
| 5 | fn 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 @@ |
| 1 | error[E0308]: mismatched types | |
| 2 | --> $DIR/pin_mut_coerce_shared.rs:8:12 | |
| 3 | | | |
| 4 | LL | 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 ()>` | |
| 11 | note: function defined here | |
| 12 | --> $DIR/pin_mut_coerce_shared.rs:3:4 | |
| 13 | | | |
| 14 | LL | fn method(a: Pin<&()>) {} | |
| 15 | | ^^^^^^ ----------- | |
| 16 | ||
| 17 | error: aborting due to 1 previous error | |
| 18 | ||
| 19 | For more information about this error, try `rustc --explain E0308`. |