Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c8663ee
Introduce CoerceShared lang item and trait
aapoalas Aug 29, 2025
fce8c13
Add reborrow CoerceShared feature gate test
aapoalas Aug 29, 2025
35bae9d
Introduce basic Reborrow tests
aapoalas Aug 30, 2025
c4a87eb
fix: Move CoerceShared into ops
aapoalas Sep 15, 2025
e32b975
tests: relax expectations after llvm change 902ddda120a5
durin42 Sep 18, 2025
9877b26
Correctly display merged doctest compilation time
GuillaumeGomez Sep 25, 2025
7a9b6d9
PassWrapper: update for new PGOOptions args in LLVM 22
durin42 Sep 25, 2025
68c0e97
re-order normalizations in run-make linker-warning test
Fabian-Gruenbichler Sep 25, 2025
c0e0d4b
Make `def_path_hash_to_def_id` not panic when passed an invalid hash
Lysxia Sep 26, 2025
4c7292a
PassWrapper: drop unused variable for LLVM 22+
durin42 Sep 26, 2025
99456cc
tests: use max-llvm-major-version instead of ignore-llvm-version
durin42 Sep 26, 2025
2e904c4
update issue number for more_float_constants
joshuarayton Sep 26, 2025
852aa20
Rename `rust.use-lld` to `rust.bootstrap-override-lld`
Kobzol Sep 25, 2025
bd860bd
Fix typo in LLVM_VERSION_ macro use
durin42 Sep 26, 2025
b7e444d
Add regression test for merged doctests compilation time display
GuillaumeGomez Sep 25, 2025
e88fa08
move Reborrow to ops, fix fmt issues
aapoalas Sep 26, 2025
01c17f8
Rollup merge of #146037 - aapoalas:reborrow-lang-experiment, r=tmandry
matthiaskrgr Sep 27, 2025
c772af7
Rollup merge of #146732 - durin42:llvm-22-less-assumes, r=nikic
matthiaskrgr Sep 27, 2025
13ac606
Rollup merge of #147018 - Fabian-Gruenbichler:mr/fix-linker-warning-t…
matthiaskrgr Sep 27, 2025
a11a211
Rollup merge of #147032 - GuillaumeGomez:fix-doctest-compilation-time…
matthiaskrgr Sep 27, 2025
82dff12
Rollup merge of #147046 - Kobzol:bootstrap-ll, r=jieyouxu
matthiaskrgr Sep 27, 2025
848009f
Rollup merge of #147050 - durin42:llvm-22-pgo-options-args, r=cuviper
matthiaskrgr Sep 27, 2025
a2b77d0
Rollup merge of #147075 - Lysxia:no-panic-def-path-hash, r=petrochenkov
matthiaskrgr Sep 27, 2025
bd2e186
Rollup merge of #147076 - joshuarayton:more-float-constants-issue, r=…
matthiaskrgr Sep 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -768,16 +768,15 @@
# make this default to false.
#rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true

# Indicates whether LLD will be used to link Rust crates during bootstrap on
# supported platforms.
# Indicates if we should override the linker used to link Rust crates during bootstrap to be LLD.
# If set to `true` or `"external"`, a global `lld` binary that has to be in $PATH
# will be used.
# If set to `"self-contained"`, rust-lld from the snapshot compiler will be used.
#
# On MSVC, LLD will not be used if we're cross linking.
#
# Explicitly setting the linker for a target will override this option when targeting MSVC.
#rust.use-lld = false
#rust.bootstrap-override-lld = false

# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
# sysroot.
Expand Down Expand Up @@ -950,7 +949,7 @@
# Linker to be used to bootstrap Rust code. Note that the
# default value is platform specific, and if not specified it may also depend on
# what platform is crossing to what platform.
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
# Setting this will override the `bootstrap-override-lld` option for Rust code when targeting MSVC.
#linker = "cc" (path)

# Should rustc and the standard library be built with split debuginfo? Default
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ language_item_table! {

// Reborrowing related lang-items
Reborrow, sym::reborrow, reborrow, Target::Trait, GenericRequirement::Exact(0);
CoerceShared, sym::coerce_shared, coerce_shared, Target::Trait, GenericRequirement::Exact(0);
}

/// The requirement imposed on the generics of a lang item
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,25 +569,43 @@ extern "C" LLVMRustResult LLVMRustOptimize(
}

std::optional<PGOOptions> PGOOpt;
#if LLVM_VERSION_LT(22, 0)
auto FS = vfs::getRealFileSystem();
#endif
if (PGOGenPath) {
assert(!PGOUsePath && !PGOSampleUsePath);
PGOOpt = PGOOptions(
#if LLVM_VERSION_GE(22, 0)
PGOGenPath, "", "", "", PGOOptions::IRInstr, PGOOptions::NoCSAction,
#else
PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction,
#endif
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
} else if (PGOUsePath) {
assert(!PGOSampleUsePath);
PGOOpt = PGOOptions(
#if LLVM_VERSION_GE(22, 0)
PGOUsePath, "", "", "", PGOOptions::IRUse, PGOOptions::NoCSAction,
#else
PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction,
#endif
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
} else if (PGOSampleUsePath) {
PGOOpt =
#if LLVM_VERSION_GE(22, 0)
PGOOptions(PGOSampleUsePath, "", "", "", PGOOptions::SampleUse,
#else
PGOOptions(PGOSampleUsePath, "", "", "", FS, PGOOptions::SampleUse,
#endif
PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
DebugInfoForProfiling);
} else if (DebugInfoForProfiling) {
PGOOpt = PGOOptions(
#if LLVM_VERSION_GE(22, 0)
"", "", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
#else
"", "", "", "", FS, PGOOptions::NoAction, PGOOptions::NoCSAction,
#endif
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ impl<'a> CrateMetadataRef<'a> {
}

#[inline]
fn def_path_hash_to_def_index(self, hash: DefPathHash) -> DefIndex {
fn def_path_hash_to_def_index(self, hash: DefPathHash) -> Option<DefIndex> {
self.def_path_hash_map.def_path_hash_to_def_index(&hash)
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ fn provide_cstore_hooks(providers: &mut Providers) {
.get(&stable_crate_id)
.unwrap_or_else(|| bug!("uninterned StableCrateId: {stable_crate_id:?}"));
assert_ne!(cnum, LOCAL_CRATE);
let def_index = cstore.get_crate_data(cnum).def_path_hash_to_def_index(hash);
DefId { krate: cnum, index: def_index }
let def_index = cstore.get_crate_data(cnum).def_path_hash_to_def_index(hash)?;
Some(DefId { krate: cnum, index: def_index })
};

providers.hooks.expn_hash_to_expn_id = |tcx, cnum, index_guess, hash| {
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ pub(crate) enum DefPathHashMapRef<'tcx> {

impl DefPathHashMapRef<'_> {
#[inline]
pub(crate) fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
pub(crate) fn def_path_hash_to_def_index(
&self,
def_path_hash: &DefPathHash,
) -> Option<DefIndex> {
match *self {
DefPathHashMapRef::OwnedFromMetadata(ref map) => {
map.get(&def_path_hash.local_hash()).unwrap()
}
DefPathHashMapRef::OwnedFromMetadata(ref map) => map.get(&def_path_hash.local_hash()),
DefPathHashMapRef::BorrowedFromTcx(_) => {
panic!("DefPathHashMap::BorrowedFromTcx variant only exists for serialization")
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/hooks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ declare_hooks! {
/// session, if it still exists. This is used during incremental compilation to
/// turn a deserialized `DefPathHash` into its current `DefId`.
/// Will fetch a DefId from a DefPathHash for a foreign crate.
hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> DefId;
hook def_path_hash_to_def_id_extern(hash: DefPathHash, stable_crate_id: StableCrateId) -> Option<DefId>;

/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
/// can just link to the upstream crate and therefore don't need a mono item.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ impl<'tcx> TyCtxt<'tcx> {
if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) {
Some(self.untracked.definitions.read().local_def_path_hash_to_def_id(hash)?.to_def_id())
} else {
Some(self.def_path_hash_to_def_id_extern(hash, stable_crate_id))
self.def_path_hash_to_def_id_extern(hash, stable_crate_id)
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ symbols! {
cmpxchg16b_target_feature,
cmse_nonsecure_entry,
coerce_pointee_validated,
coerce_shared,
coerce_unsized,
cold,
cold_path,
Expand Down
8 changes: 0 additions & 8 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,11 +1341,3 @@ pub macro CoercePointee($item:item) {
pub trait CoercePointeeValidated {
/* compiler built-in */
}

/// Allows value to be reborrowed as exclusive, creating a copy of the value
/// that disables the source for reads and writes for the lifetime of the copy.
#[lang = "reborrow"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait Reborrow {
// Empty.
}
12 changes: 6 additions & 6 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ pub mod consts {

/// The golden ratio (φ)
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const PHI: f128 = 1.61803398874989484820458683436563811772030917980576286213545_f128;

/// The Euler-Mascheroni constant (γ)
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128;

/// π/2
Expand Down Expand Up @@ -67,14 +67,14 @@ pub mod consts {

/// 1/sqrt(π)
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_PI: f128 =
0.564189583547756286948079451560772585844050629328998856844086_f128;

/// 1/sqrt(2π)
#[doc(alias = "FRAC_1_SQRT_TAU")]
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_2PI: f128 =
0.398942280401432677939946059934381868475858631164934657665926_f128;

Expand All @@ -98,12 +98,12 @@ pub mod consts {

/// sqrt(3)
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const SQRT_3: f128 = 1.73205080756887729352744634150587236694280525381038062805581_f128;

/// 1/sqrt(3)
#[unstable(feature = "f128", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_3: f128 =
0.577350269189625764509148780501957455647601751270126876018602_f128;

Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub mod consts {

/// The golden ratio (φ)
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const PHI: f16 = 1.618033988749894848204586834365638118_f16;

/// The Euler-Mascheroni constant (γ)
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16;

/// π/2
Expand Down Expand Up @@ -69,13 +69,13 @@ pub mod consts {

/// 1/sqrt(π)
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16;

/// 1/sqrt(2π)
#[doc(alias = "FRAC_1_SQRT_TAU")]
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_2PI: f16 = 0.398942280401432677939946059934381868_f16;

/// 2/π
Expand All @@ -96,12 +96,12 @@ pub mod consts {

/// sqrt(3)
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const SQRT_3: f16 = 1.732050807568877293527446341505872367_f16;

/// 1/sqrt(3)
#[unstable(feature = "f16", issue = "116909")]
// Also, #[unstable(feature = "more_float_constants", issue = "103883")]
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_3: f16 = 0.577350269189625764509148780501957456_f16;

/// Euler's number (e)
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ pub mod consts {
pub const TAU: f32 = 6.28318530717958647692528676655900577_f32;

/// The golden ratio (φ)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const PHI: f32 = 1.618033988749894848204586834365638118_f32;

/// The Euler-Mascheroni constant (γ)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const EGAMMA: f32 = 0.577215664901532860606512090082402431_f32;

/// π/2
Expand Down Expand Up @@ -323,12 +323,12 @@ pub mod consts {
pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724_f32;

/// 1/sqrt(π)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_PI: f32 = 0.564189583547756286948079451560772586_f32;

/// 1/sqrt(2π)
#[doc(alias = "FRAC_1_SQRT_TAU")]
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_2PI: f32 = 0.398942280401432677939946059934381868_f32;

/// 2/π
Expand All @@ -348,11 +348,11 @@ pub mod consts {
pub const FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039_f32;

/// sqrt(3)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const SQRT_3: f32 = 1.732050807568877293527446341505872367_f32;

/// 1/sqrt(3)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_3: f32 = 0.577350269189625764509148780501957456_f32;

/// Euler's number (e)
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ pub mod consts {
pub const TAU: f64 = 6.28318530717958647692528676655900577_f64;

/// The golden ratio (φ)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const PHI: f64 = 1.618033988749894848204586834365638118_f64;

/// The Euler-Mascheroni constant (γ)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64;

/// π/2
Expand Down Expand Up @@ -323,12 +323,12 @@ pub mod consts {
pub const FRAC_1_PI: f64 = 0.318309886183790671537767526745028724_f64;

/// 1/sqrt(π)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64;

/// 1/sqrt(2π)
#[doc(alias = "FRAC_1_SQRT_TAU")]
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64;

/// 2/π
Expand All @@ -348,11 +348,11 @@ pub mod consts {
pub const FRAC_1_SQRT_2: f64 = 0.707106781186547524400844362104849039_f64;

/// sqrt(3)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const SQRT_3: f64 = 1.732050807568877293527446341505872367_f64;

/// 1/sqrt(3)
#[unstable(feature = "more_float_constants", issue = "103883")]
#[unstable(feature = "more_float_constants", issue = "146939")]
pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64;

/// Euler's number (e)
Expand Down
3 changes: 3 additions & 0 deletions library/core/src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ mod function;
mod index;
mod index_range;
mod range;
mod reborrow;
mod try_trait;
mod unsize;

Expand Down Expand Up @@ -189,6 +190,8 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
pub use self::range::{OneSidedRange, OneSidedRangeBound};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
#[unstable(feature = "reborrow", issue = "145612")]
pub use self::reborrow::{CoerceShared, Reborrow};
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
pub use self::try_trait::Residual;
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
Expand Down
16 changes: 16 additions & 0 deletions library/core/src/ops/reborrow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// Allows value to be reborrowed as exclusive, creating a copy of the value
/// that disables the source for reads and writes for the lifetime of the copy.
#[lang = "reborrow"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait Reborrow {
// Empty.
}

/// Allows reborrowable value to be reborrowed as shared, creating a copy
/// that disables the source for writes for the lifetime of the copy.
#[lang = "coerce_shared"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait CoerceShared: Reborrow {
/// The type of this value when reborrowed as shared.
type Target: Copy;
}
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ pub fn rustc_cargo(
// us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object
// with direct references to protected symbols, so for now we only use protected symbols if
// linking with LLD is enabled.
if builder.build.config.lld_mode.is_used() {
if builder.build.config.bootstrap_override_lld.is_used() {
cargo.rustflag("-Zdefault-visibility=protected");
}

Expand Down Expand Up @@ -1258,7 +1258,7 @@ pub fn rustc_cargo(
// is already on by default in MSVC optimized builds, which is interpreted as --icf=all:
// https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746
// https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827
if builder.config.lld_mode.is_used() && !build_compiler.host.is_msvc() {
if builder.config.bootstrap_override_lld.is_used() && !build_compiler.host.is_msvc() {
cargo.rustflag("-Clink-args=-Wl,--icf=all");
}

Expand Down
Loading
Loading