Skip to content

Rollup of 8 pull requests #143105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0cdd7f5
Add all rustc_std_internal_symbol to symbols.o
bjorn3 May 8, 2025
5f63b57
Remove dependency injection for the panic runtime
bjorn3 May 8, 2025
5dfe72c
Stop handling explicit dependencies on the panic runtime
bjorn3 May 8, 2025
6d3ff39
Avoid exporting panic_unwind as stdlib cargo feature
bjorn3 May 8, 2025
c44a23c
Make comment on activate_injected_dep a doc comment
bjorn3 May 9, 2025
b9c0f15
Fix LTO for internalizing rustc_std_internal_symbol symbols
bjorn3 Jun 17, 2025
f5af05b
Fix circular dependency test to use rustc_std_internal_symbol
bjorn3 Jun 17, 2025
0c405ae
Update version placeholders
cuviper Jun 23, 2025
1e9c63f
Update stage0 to 1.89.0-beta.1
cuviper Jun 24, 2025
c388e68
Update `STAGE0_MISSING_TARGETS`
cuviper Jun 24, 2025
6cacbc7
Update `cfg(bootstrap)`
cuviper Jun 24, 2025
18f4cb1
Extract const boundness parsing out into a method
oli-obk Apr 1, 2025
e0f8e86
Skip unnecessary components in x64 try builds
Kobzol Jun 24, 2025
25dee4e
Skip more dist components
Kobzol Jun 24, 2025
8034154
Do not build GCC in fast try builds
Kobzol Jun 24, 2025
58bc1dc
Remove `mut`
Kobzol Jun 25, 2025
eb7245a
Change const trait bound syntax from ~const to [const]
oli-obk Mar 11, 2025
512ff95
Rename `tilde const` test files to `conditionally const`
oli-obk Jun 26, 2025
b2be01c
rustdoc: show attributes on enum variants
lolbinarycat Jun 24, 2025
4573c84
tests: Require `run-fail` ui tests to have an exit code (`SIGABRT` no…
Enselic Jun 25, 2025
4b77115
Update comments
bjorn3 Jun 27, 2025
d0fa026
const checks: avoid 'top-level scope' terminology
RalfJung Jun 27, 2025
5af7924
tag_for_variant: properly pass TypingEnv
RalfJung Jun 27, 2025
14fbe94
Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
compiler-errors Jun 27, 2025
4125bee
Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=petrochenkov
compiler-errors Jun 27, 2025
ce858dd
Rollup merge of #142963 - Kobzol:try-build-skip, r=jieyouxu
compiler-errors Jun 27, 2025
8d1e320
Rollup merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrum
compiler-errors Jun 27, 2025
9f7141a
Rollup merge of #142987 - lolbinarycat:rustdoc-non_exhaustive-enum-v-…
compiler-errors Jun 27, 2025
956c598
Rollup merge of #143002 - Enselic:tests-ui-run-fail-exit-vs-signal, r…
compiler-errors Jun 27, 2025
4f1e034
Rollup merge of #143092 - RalfJung:const-check-lifetime-ext, r=oli-obk
compiler-errors Jun 27, 2025
900341f
Rollup merge of #143096 - RalfJung:tag_for_variant, r=compiler-errors
compiler-errors Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl ParenthesizedArgs {

pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};

/// Modifiers on a trait bound like `~const`, `?` and `!`.
/// Modifiers on a trait bound like `[const]`, `?` and `!`.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
pub struct TraitBoundModifiers {
pub constness: BoundConstness,
Expand Down Expand Up @@ -3115,7 +3115,7 @@ pub enum BoundConstness {
Never,
/// `Type: const Trait`
Always(Span),
/// `Type: ~const Trait`
/// `Type: [const] Trait`
Maybe(Span),
}

Expand All @@ -3124,7 +3124,7 @@ impl BoundConstness {
match self {
Self::Never => "",
Self::Always(_) => "const",
Self::Maybe(_) => "~const",
Self::Maybe(_) => "[const]",
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ ast_passes_static_without_body =
free static item without body
.suggestion = provide a definition for the static
ast_passes_tilde_const_disallowed = `~const` is not allowed here
.closure = closures cannot have `~const` trait bounds
.function = this function is not `const`, so it cannot have `~const` trait bounds
.trait = this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
.trait_impl = this impl is not `const`, so it cannot have `~const` trait bounds
.impl = inherent impls cannot have `~const` trait bounds
.trait_assoc_ty = associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds
.trait_impl_assoc_ty = associated types in non-const impls cannot have `~const` trait bounds
.inherent_assoc_ty = inherent associated types cannot have `~const` trait bounds
.object = trait objects cannot have `~const` trait bounds
.item = this item cannot have `~const` trait bounds
ast_passes_tilde_const_disallowed = `[const]` is not allowed here
.closure = closures cannot have `[const]` trait bounds
.function = this function is not `const`, so it cannot have `[const]` trait bounds
.trait = this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds
.trait_impl = this impl is not `const`, so it cannot have `[const]` trait bounds
.impl = inherent impls cannot have `[const]` trait bounds
.trait_assoc_ty = associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds
.trait_impl_assoc_ty = associated types in non-const impls cannot have `[const]` trait bounds
.inherent_assoc_ty = inherent associated types cannot have `[const]` trait bounds
.object = trait objects cannot have `[const]` trait bounds
.item = this item cannot have `[const]` trait bounds
ast_passes_trait_fn_const =
functions in {$in_impl ->
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(not(bootstrap), feature(autodiff))]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(autodiff)]
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(if_let_guard)]
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1876,12 +1876,28 @@ pub(crate) fn linked_symbols(
}
}

match tcx.sess.lto() {
Lto::No | Lto::ThinLocal => {}
Lto::Thin | Lto::Fat => {
// We really only need symbols from upstream rlibs to end up in the linked symbols list.
// The rest are in separate object files which the linker will always link in and
// doesn't have rules around the order in which they need to appear.
// When doing LTO, some of the symbols in the linked symbols list happen to be
// internalized by LTO, which then prevents referencing them from symbols.o. When doing
// LTO, all object files that get linked in will be local object files rather than
// pulled in from rlibs, so an empty linked symbols list works fine to avoid referencing
// all those internalized symbols from symbols.o.
return Vec::new();
}
}

let mut symbols = Vec::new();

let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum)
|| info.used
|| info.rustc_std_internal_symbol
{
symbols.push((
symbol_export::linking_symbol_name_for_instance_in_crate(
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
|| used,
rustc_std_internal_symbol: codegen_attrs
.flags
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),
};
(def_id.to_def_id(), info)
})
Expand All @@ -143,6 +146,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
);
}
Expand Down Expand Up @@ -191,6 +195,7 @@ fn exported_symbols_provider_local<'tcx>(
level: info.level,
kind: SymbolExportKind::Text,
used: info.used,
rustc_std_internal_symbol: info.rustc_std_internal_symbol,
},
)
})
Expand All @@ -207,6 +212,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -230,6 +236,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: true,
},
));
}
Expand All @@ -250,6 +257,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
)
}));
Expand All @@ -275,6 +283,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
)
}));
Expand All @@ -292,6 +301,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: true,
rustc_std_internal_symbol: false,
},
));
}
Expand Down Expand Up @@ -367,6 +377,8 @@ fn exported_symbols_provider_local<'tcx>(
}
}

// Note: These all set rustc_std_internal_symbol to false as generic functions must not
// be marked with this attribute and we are only handling generic functions here.
match *mono_item {
MonoItem::Fn(Instance { def: InstanceKind::Item(def), args }) => {
let has_generics = args.non_erasable_generics().next().is_some();
Expand All @@ -382,6 +394,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -404,6 +417,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -420,6 +434,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -430,6 +445,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand Down
22 changes: 1 addition & 21 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::time::{Duration, Instant};
use itertools::Itertools;
use rustc_abi::FIRST_VARIANT;
use rustc_ast as ast;
use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_name};
use rustc_ast::expand::allocator::AllocatorKind;
use rustc_attr_data_structures::OptimizeAttr;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
Expand Down Expand Up @@ -1056,26 +1056,6 @@ impl CrateInfo {
.collect::<Vec<_>>();
symbols.sort_unstable_by(|a, b| a.0.cmp(&b.0));
linked_symbols.extend(symbols);
if tcx.allocator_kind(()).is_some() {
// At least one crate needs a global allocator. This crate may be placed
// after the crate that defines it in the linker order, in which case some
// linkers return an error. By adding the global allocator shim methods to
// the linked_symbols list, linking the generated symbols.o will ensure that
// circular dependencies involving the global allocator don't lead to linker
// errors.
linked_symbols.extend(ALLOCATOR_METHODS.iter().map(|method| {
(
add_prefix(
mangle_internal_symbol(
tcx,
global_fn_name(method.name).as_str(),
),
SymbolExportKind::Text,
),
SymbolExportKind::Text,
)
}));
}
});
}

Expand Down
28 changes: 10 additions & 18 deletions compiler/rustc_const_eval/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,11 @@ const_eval_incompatible_types =
calling a function with argument of type {$callee_ty} passing data of type {$caller_ty}

const_eval_interior_mutable_borrow_escaping =
interior mutable shared borrows of lifetime-extended temporaries in the top-level scope of a {const_eval_const_context} are not allowed
.label = this borrow of an interior mutable value refers to a lifetime-extended temporary
.help = to fix this, the value can be extracted to a separate `static` item and then referenced
.teach_note =
This creates a raw pointer to a temporary that has its lifetime extended to last for the entire program.
Lifetime-extended temporaries in constants and statics must be immutable.
This is to avoid accidentally creating shared mutable state.


If you really want global mutable state, try using an interior mutable `static` or a `static mut`.
interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed
.label = this borrow of an interior mutable value refers to such a temporary
.note = Temporaries in constants and statics can have their lifetime extended until the end of the program
.note2 = To avoid accidentally creating global mutable state, such temporaries must be immutable
.help = If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`

const_eval_intern_kind = {$kind ->
[static] static
Expand Down Expand Up @@ -215,14 +210,11 @@ const_eval_modified_global =
modifying a static's initial value from another static's initializer

const_eval_mutable_borrow_escaping =
mutable borrows of lifetime-extended temporaries in the top-level scope of a {const_eval_const_context} are not allowed
.teach_note =
This creates a reference to a temporary that has its lifetime extended to last for the entire program.
Lifetime-extended temporaries in constants and statics must be immutable.
This is to avoid accidentally creating shared mutable state.


If you really want global mutable state, try using an interior mutable `static` or a `static mut`.
mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed
.label = this mutable borrow refers to such a temporary
.note = Temporaries in constants and statics can have their lifetime extended until the end of the program
.note2 = To avoid accidentally creating global mutable state, such temporaries must be immutable
.help = If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut`

const_eval_mutable_ptr_in_final = encountered mutable pointer in final value of {const_eval_intern_kind}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
Some(ConstConditionsHold::Yes)
} else {
tcx.dcx()
.span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
.span_delayed_bug(call_span, "this should have reported a [const] error in HIR");
Some(ConstConditionsHold::No)
}
}
Expand Down
15 changes: 3 additions & 12 deletions compiler/rustc_const_eval/src/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
debug!(?param_ty);
if let Some(generics) = tcx.hir_node_by_def_id(caller).generics() {
let constraint = with_no_trimmed_paths!(format!(
"~const {}",
"[const] {}",
trait_ref.print_trait_sugared(),
));
suggest_constraining_type_param(
Expand Down Expand Up @@ -567,12 +567,7 @@ impl<'tcx> NonConstOp<'tcx> for EscapingCellBorrow {
DiagImportance::Secondary
}
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::InteriorMutableBorrowEscaping {
span,
opt_help: matches!(ccx.const_kind(), hir::ConstContext::Static(_)),
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0492),
})
ccx.dcx().create_err(errors::InteriorMutableBorrowEscaping { span, kind: ccx.const_kind() })
}
}

Expand All @@ -594,11 +589,7 @@ impl<'tcx> NonConstOp<'tcx> for EscapingMutBorrow {
}

fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::MutableBorrowEscaping {
span,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0764),
})
ccx.dcx().create_err(errors::MutableBorrowEscaping { span, kind: ccx.const_kind() })
}
}

Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ impl Qualif for NeedsNonConstDrop {

#[instrument(level = "trace", skip(cx), ret)]
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
// If this doesn't need drop at all, then don't select `~const Destruct`.
// If this doesn't need drop at all, then don't select `[const] Destruct`.
if !ty.needs_drop(cx.tcx, cx.typing_env) {
return false;
}

// We check that the type is `~const Destruct` since that will verify that
// the type is both `~const Drop` (if a drop impl exists for the adt), *and*
// that the components of this type are also `~const Destruct`. This
// We check that the type is `[const] Destruct` since that will verify that
// the type is both `[const] Drop` (if a drop impl exists for the adt), *and*
// that the components of this type are also `[const] Destruct`. This
// amounts to verifying that there are no values in this ADT that may have
// a non-const drop.
let destruct_def_id = cx.tcx.require_lang_item(LangItem::Destruct, cx.body.span);
Expand All @@ -203,9 +203,9 @@ impl Qualif for NeedsNonConstDrop {
fn is_structural_in_adt_value<'tcx>(cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {
// As soon as an ADT has a destructor, then the drop becomes non-structural
// in its value since:
// 1. The destructor may have `~const` bounds which are not present on the type.
// 1. The destructor may have `[const]` bounds which are not present on the type.
// Someone needs to check that those are satisfied.
// While this could be instead satisfied by checking that the `~const Drop`
// While this could be instead satisfied by checking that the `[const] Drop`
// impl holds (i.e. replicating part of the `in_any_value_of_ty` logic above),
// even in this case, we have another problem, which is,
// 2. The destructor may *modify* the operand being dropped, so even if we
Expand Down
13 changes: 4 additions & 9 deletions compiler/rustc_const_eval/src/const_eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,13 @@ pub(crate) fn try_destructure_mir_constant_for_user_output<'tcx>(
#[instrument(skip(tcx), level = "debug")]
pub fn tag_for_variant_provider<'tcx>(
tcx: TyCtxt<'tcx>,
(ty, variant_index): (Ty<'tcx>, VariantIdx),
key: ty::PseudoCanonicalInput<'tcx, (Ty<'tcx>, VariantIdx)>,
) -> Option<ty::ScalarInt> {
let (ty, variant_index) = key.value;
assert!(ty.is_enum());

// FIXME: This uses an empty `TypingEnv` even though
// it may be used by a generic CTFE.
let ecx = InterpCx::new(
tcx,
ty.default_span(tcx),
ty::TypingEnv::fully_monomorphized(),
crate::const_eval::DummyMachine,
);
let ecx =
InterpCx::new(tcx, ty.default_span(tcx), key.typing_env, crate::const_eval::DummyMachine);

let layout = ecx.layout_of(ty).unwrap();
ecx.tag_for_variant(layout, variant_index).unwrap().map(|(tag, _tag_field)| tag)
Expand Down
Loading
Loading