Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
14795f0
slightly extend PR creation message
RalfJung Nov 5, 2025
4384d43
Prepare for merging from rust-lang/rust
Nov 6, 2025
bca4136
Merge ref '401ae5542752' from rust-lang/rust
Nov 6, 2025
3d08696
fmt
Nov 6, 2025
29c28b3
Merge pull request #4671 from rust-lang/rustup-2025-11-06
RalfJung Nov 6, 2025
6b394d4
Merge pull request #4669 from RalfJung/triagebot-welcome
RalfJung Nov 6, 2025
8d597aa
Remove implementation of LLVM SIMD intrinsics that are not needed any…
eduardosm Nov 4, 2025
2760570
Merge pull request #4667 from eduardosm/remove-intrinsics
RalfJung Nov 6, 2025
d59e58b
Use the dummy codegen backend
bjorn3 Oct 23, 2025
ccdb1c0
Merge pull request #4648 from bjorn3/dummy_backend
RalfJung Nov 6, 2025
7711eb9
lazy_sync: ensure the cookie fits inside the primitive
RalfJung Nov 6, 2025
b8eee76
./miri run: verbose by default, add flag to be quiet
RalfJung Nov 4, 2025
384c05f
fix 'cargo miri setup' quietness
RalfJung Nov 7, 2025
4ddc3ad
Merge pull request #4665 from RalfJung/run-verbose
RalfJung Nov 7, 2025
f6b751e
Prepare for merging from rust-lang/rust
Nov 8, 2025
c7da7c3
Merge ref 'ceb7df7e6f17' from rust-lang/rust
Nov 8, 2025
8aedbf1
Replace `#[const_trait]` with `const` in libcore
fmease Nov 8, 2025
c262920
Remove `#[const_trait]`
fmease Nov 7, 2025
f796155
Merge pull request #4673 from rust-lang/rustup-2025-11-08
oli-obk Nov 8, 2025
52fd48c
std: use a non-poisoning `RwLock` for the panic hook
joboet Nov 8, 2025
edc13e6
pthread: replace INIT_COOKIE by sync object metadata that gets cleare…
RalfJung Nov 6, 2025
ba789c6
also use new sync obj metadata scheme for INIT_ONCE and os_unfair_lock
RalfJung Nov 7, 2025
155b09f
throw an error if a synchronization object is read/written while thre…
RalfJung Nov 7, 2025
3c4b29c
remove dead code
RalfJung Nov 7, 2025
d6b01ab
also inform sync objcts about deallocation; needs separate AccessKind…
RalfJung Nov 8, 2025
e14780a
Merge pull request #4672 from RalfJung/sync-objs
RalfJung Nov 8, 2025
7eb5492
fix: disable self-contained linker when bootstrap-override-lld is set
karolzwolak Nov 8, 2025
3fdde5f
Add Crystal Durham to .mailmap
CAD97 Nov 8, 2025
610391f
bootstrap: Render doctest timing reports as text, not JSON
Zalathar Nov 9, 2025
38ae449
tidy: Don't bypass stderr output capture in unit tests
Zalathar Nov 9, 2025
e56de95
Fix `#[type_const]` attribute placement validation
camelid Nov 8, 2025
c0939d4
Perform WF-checking on type_const RHS's
camelid Nov 8, 2025
9ba8932
Check type_const type is ConstParamTy_ and that RHS matches it
camelid Nov 8, 2025
db2fbdb
Check that impls of `#[type_const]` consts also have the attr
camelid Nov 8, 2025
1496ffa
Fix typo in unstable-book link.
luca3s Nov 9, 2025
479df91
Add myself(chenyukang) to the review rotation
chenyukang Nov 9, 2025
e5a69bb
Rollup merge of #148683 - fmease:rm-const_trait-attr, r=fee1-dead
matthiaskrgr Nov 9, 2025
243d494
Rollup merge of #148687 - joboet:nonpoison-hook-rwlock, r=ChrisDenton
matthiaskrgr Nov 9, 2025
7df5f5c
Rollup merge of #148709 - karolzwolak:bootstrap-override-lld-should-d…
matthiaskrgr Nov 9, 2025
7e9b67d
Rollup merge of #148716 - camelid:finish-type_const, r=BoxyUwU
matthiaskrgr Nov 9, 2025
fb571c9
Rollup merge of #148722 - CAD97:git-dislikes-my-emoji, r=Mark-Simulacrum
matthiaskrgr Nov 9, 2025
d08475a
Rollup merge of #148723 - Zalathar:bootstrap-doctest, r=jieyouxu
matthiaskrgr Nov 9, 2025
f94ad14
Rollup merge of #148724 - Zalathar:tidyselftest, r=jieyouxu
matthiaskrgr Nov 9, 2025
2fffcf0
Rollup merge of #148734 - RalfJung:miri, r=RalfJung
matthiaskrgr Nov 9, 2025
afa0e75
Rollup merge of #148736 - luca3s:fix-typo, r=Zalathar
matthiaskrgr Nov 9, 2025
a2c4f03
Rollup merge of #148744 - chenyukang:yukang-add-to-rotation, r=jieyouxu
matthiaskrgr Nov 9, 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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ Christian Poveda <git@pvdrz.com> <31802960+christianpoveda@users.noreply.github.
Christian Poveda <git@pvdrz.com> <christianpoveda@uhura.edef.eu>
Christian Vallentin <vallentinsource@gmail.com>
Christoffer Buchholz <chris@chrisbuchholz.me>
Christopher Durham <cad97@cad97.com>
Clark Gaebel <cg.wowus.cg@gmail.com> <cgaebel@mozilla.com>
Clement Miao <clementmiao@gmail.com>
Clément Renault <renault.cle@gmail.com>
Expand All @@ -148,6 +147,7 @@ Clinton Ryan <clint.ryan3@gmail.com>
Taylor Cramer <cramertaylorj@gmail.com> <cramertj@google.com>
ember arlynx <ember@lunar.town> <corey@octayn.net>
Crazycolorz5 <Crazycolorz5@gmail.com>
Crystal Durham <cad97@cad97.com>
csmoe <35686186+csmoe@users.noreply.github.com>
Cyryl Płotnicki <cyplo@cyplo.net>
Damien Schoof <damien.schoof@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ ast_passes_trait_fn_const =
*[false] {""}
}
.make_impl_const_sugg = ... and declare the impl to be const instead
.make_trait_const_sugg = ... and declare the trait to be a `#[const_trait]` instead
.make_trait_const_sugg = ... and declare the trait to be const instead
ast_passes_trait_object_single_bound = only a single explicit lifetime bound is permitted
Expand Down
23 changes: 9 additions & 14 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum SelfSemantic {
}

enum TraitOrTraitImpl {
Trait { span: Span, constness: Const },
Trait { vis: Span, constness: Const },
TraitImpl { constness: Const, polarity: ImplPolarity, trait_ref_span: Span },
}

Expand Down Expand Up @@ -109,10 +109,10 @@ impl<'a> AstValidator<'a> {
self.outer_trait_or_trait_impl = old;
}

fn with_in_trait(&mut self, span: Span, constness: Const, f: impl FnOnce(&mut Self)) {
fn with_in_trait(&mut self, vis: Span, constness: Const, f: impl FnOnce(&mut Self)) {
let old = mem::replace(
&mut self.outer_trait_or_trait_impl,
Some(TraitOrTraitImpl::Trait { span, constness }),
Some(TraitOrTraitImpl::Trait { vis, constness }),
);
f(self);
self.outer_trait_or_trait_impl = old;
Expand Down Expand Up @@ -265,10 +265,12 @@ impl<'a> AstValidator<'a> {
None
};

let map = self.sess.source_map();

let make_trait_const_sugg = if const_trait_impl
&& let TraitOrTraitImpl::Trait { span, constness: ast::Const::No } = parent
&& let &TraitOrTraitImpl::Trait { vis, constness: ast::Const::No } = parent
{
Some(span.shrink_to_lo())
Some(map.span_extend_while_whitespace(vis).shrink_to_hi())
} else {
None
};
Expand All @@ -279,7 +281,7 @@ impl<'a> AstValidator<'a> {
in_impl: matches!(parent, TraitOrTraitImpl::TraitImpl { .. }),
const_context_label: parent_constness,
remove_const_sugg: (
self.sess.source_map().span_extend_while_whitespace(span),
map.span_extend_while_whitespace(span),
match parent_constness {
Some(_) => rustc_errors::Applicability::MachineApplicable,
None => rustc_errors::Applicability::MaybeIncorrect,
Expand Down Expand Up @@ -1165,13 +1167,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
..
}) => {
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
// FIXME(const_trait_impl) remove this
let alt_const_trait_span =
attr::find_by_name(&item.attrs, sym::const_trait).map(|attr| attr.span);
let constness = match (*constness, alt_const_trait_span) {
(Const::Yes(span), _) | (Const::No, Some(span)) => Const::Yes(span),
(Const::No, None) => Const::No,
};
if *is_auto == IsAuto::Yes {
// Auto traits cannot have generics, super traits nor contain items.
self.deny_generic_params(generics, ident.span);
Expand All @@ -1188,7 +1183,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
this.visit_generics(generics);
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
});
self.with_in_trait(item.span, constness, |this| {
self.with_in_trait(item.vis.span, *constness, |this| {
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
});
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) struct TraitFnConst {
pub make_impl_const_sugg: Option<Span>,
#[suggestion(
ast_passes_make_trait_const_sugg,
code = "#[const_trait]\n",
code = "const ",
applicability = "maybe-incorrect"
)]
pub make_trait_const_sugg: Option<Span>,
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_attr_parsing/src/attributes/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ pub(crate) struct TypeConstParser;
impl<S: Stage> NoArgsAttributeParser<S> for TypeConstParser {
const PATH: &[Symbol] = &[sym::type_const];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::AssocConst)]);
const ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowList(&[Allow(Target::Const), Allow(Target::AssocConst)]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::TypeConst;
}

Expand Down Expand Up @@ -101,17 +102,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
}

// FIXME(const_trait_impl): remove this
// Const traits

pub(crate) struct ConstTraitParser;
impl<S: Stage> NoArgsAttributeParser<S> for ConstTraitParser {
const PATH: &[Symbol] = &[sym::const_trait];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstTrait;
}

// Specialization

pub(crate) struct SpecializationTraitParser;
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use crate::attributes::stability::{
};
use crate::attributes::test_attrs::{IgnoreParser, ShouldPanicParser};
use crate::attributes::traits::{
AllowIncoherentImplParser, CoinductiveParser, ConstTraitParser, DenyExplicitImplParser,
AllowIncoherentImplParser, CoinductiveParser, DenyExplicitImplParser,
DoNotImplementViaObjectParser, FundamentalParser, MarkerParser, ParenSugarParser,
PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
UnsafeSpecializationMarkerParser,
Expand Down Expand Up @@ -218,7 +218,6 @@ attribute_parsers!(
Single<WithoutArgs<ColdParser>>,
Single<WithoutArgs<ConstContinueParser>>,
Single<WithoutArgs<ConstStabilityIndirectParser>>,
Single<WithoutArgs<ConstTraitParser>>,
Single<WithoutArgs<CoroutineParser>>,
Single<WithoutArgs<DenyExplicitImplParser>>,
Single<WithoutArgs<DoNotImplementViaObjectParser>>,
Expand Down
18 changes: 8 additions & 10 deletions compiler/rustc_const_eval/src/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,23 +381,21 @@ fn build_error_for_const_call<'tcx>(
`{trait_name}` is not const",
),
);
if parent.is_local() && ccx.tcx.sess.is_nightly_build() {
if let Some(parent) = parent.as_local()
&& ccx.tcx.sess.is_nightly_build()
{
if !ccx.tcx.features().const_trait_impl() {
err.help(
"add `#![feature(const_trait_impl)]` to the crate attributes to \
enable `#[const_trait]`",
enable const traits",
);
}
let indentation = ccx
.tcx
.sess
.source_map()
.indentation_before(trait_span)
.unwrap_or_default();
let span = ccx.tcx.hir_expect_item(parent).vis_span;
let span = ccx.tcx.sess.source_map().span_extend_while_whitespace(span);
err.span_suggestion_verbose(
trait_span.shrink_to_lo(),
span.shrink_to_hi(),
format!("consider making trait `{trait_name}` const"),
format!("#[const_trait]\n{indentation}"),
"const ".to_owned(),
Applicability::MaybeIncorrect,
);
} else if !ccx.tcx.sess.is_nightly_build() {
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,14 +846,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
EncodeCrossCrate::No, experimental!(register_tool),
),

// RFC 2632
// FIXME(const_trait_impl) remove this
gated!(
const_trait, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, const_trait_impl,
"`const_trait` is a temporary placeholder for marking a trait that is suitable for `const` \
`impls` and all default bodies as `const`, which may be removed or renamed in the \
future."
),
// lang-team MCP 147
gated!(
deprecated_safe, Normal, template!(List: &[r#"since = "version", note = "...""#]), ErrorFollowing,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ pub enum AttributeKind {
/// Represents `#[rustc_const_stable_indirect]`.
ConstStabilityIndirect,

/// Represents `#[const_trait]`.
ConstTrait(Span),

/// Represents `#[coroutine]`.
Coroutine(Span),

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl AttributeKind {
ConstContinue(..) => No,
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
ConstTrait(..) => No,
Coroutine(..) => No,
Coverage(..) => No,
CrateName { .. } => No,
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3065,7 +3065,7 @@ macro_rules! expect_methods_self_kind {
$(
#[track_caller]
pub fn $name(&self) -> $ret_ty {
let $pat = &self.kind else { expect_failed(stringify!($ident), self) };
let $pat = &self.kind else { expect_failed(stringify!($name), self) };
$ret_val
}
)*
Expand All @@ -3077,7 +3077,7 @@ macro_rules! expect_methods_self {
$(
#[track_caller]
pub fn $name(&self) -> $ret_ty {
let $pat = self else { expect_failed(stringify!($ident), self) };
let $pat = self else { expect_failed(stringify!($name), self) };
$ret_val
}
)*
Expand Down Expand Up @@ -4790,6 +4790,11 @@ impl<'hir> Node<'hir> {
ForeignItemKind::Static(ty, ..) => Some(ty),
_ => None,
},
Node::GenericParam(param) => match param.kind {
GenericParamKind::Lifetime { .. } => None,
GenericParamKind::Type { default, .. } => default,
GenericParamKind::Const { ty, .. } => Some(ty),
},
_ => None,
}
}
Expand Down
60 changes: 47 additions & 13 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,22 +757,18 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
}

match tcx.def_kind(def_id) {
def_kind @ (DefKind::Static { .. } | DefKind::Const) => {
DefKind::Static { .. } => {
tcx.ensure_ok().generics_of(def_id);
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().predicates_of(def_id);
match def_kind {
DefKind::Static { .. } => {
check_static_inhabited(tcx, def_id);
check_static_linkage(tcx, def_id);
let ty = tcx.type_of(def_id).instantiate_identity();
res = res.and(wfcheck::check_static_item(
tcx, def_id, ty, /* should_check_for_sync */ true,
));
}
DefKind::Const => res = res.and(wfcheck::check_const_item(tcx, def_id)),
_ => unreachable!(),
}

check_static_inhabited(tcx, def_id);
check_static_linkage(tcx, def_id);
let ty = tcx.type_of(def_id).instantiate_identity();
res = res.and(wfcheck::check_static_item(
tcx, def_id, ty, /* should_check_for_sync */ true,
));

// Only `Node::Item` and `Node::ForeignItem` still have HIR based
// checks. Returning early here does not miss any checks and
// avoids this query from having a direct dependency edge on the HIR
Expand Down Expand Up @@ -900,6 +896,39 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
// avoids this query from having a direct dependency edge on the HIR
return res;
}
DefKind::Const => {
tcx.ensure_ok().generics_of(def_id);
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().predicates_of(def_id);

res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
let ty = tcx.type_of(def_id).instantiate_identity();
let ty_span = tcx.ty_span(def_id);
let ty = wfcx.deeply_normalize(ty_span, Some(WellFormedLoc::Ty(def_id)), ty);
wfcx.register_wf_obligation(ty_span, Some(WellFormedLoc::Ty(def_id)), ty.into());
wfcx.register_bound(
traits::ObligationCause::new(
ty_span,
def_id,
ObligationCauseCode::SizedConstOrStatic,
),
tcx.param_env(def_id),
ty,
tcx.require_lang_item(LangItem::Sized, ty_span),
);
check_where_clauses(wfcx, def_id);

if find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TypeConst(_)) {
wfcheck::check_type_const(wfcx, def_id, ty, true)?;
}
Ok(())
}));

// Only `Node::Item` and `Node::ForeignItem` still have HIR based
// checks. Returning early here does not miss any checks and
// avoids this query from having a direct dependency edge on the HIR
return res;
}
DefKind::TyAlias => {
tcx.ensure_ok().generics_of(def_id);
tcx.ensure_ok().type_of(def_id);
Expand All @@ -920,6 +949,11 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
}));
check_variances_for_type_defn(tcx, def_id);
}

// Only `Node::Item` and `Node::ForeignItem` still have HIR based
// checks. Returning early here does not miss any checks and
// avoids this query from having a direct dependency edge on the HIR
return res;
}
DefKind::ForeignMod => {
let it = tcx.hir_expect_item(def_id);
Expand Down
37 changes: 36 additions & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use hir::def_id::{DefId, DefIdMap, LocalDefId};
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::codes::*;
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, pluralize, struct_span_code_err};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::VisitorExt;
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, intravisit};
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, find_attr, intravisit};
use rustc_infer::infer::{self, BoundRegionConversionTime, InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::util;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
Expand Down Expand Up @@ -1984,12 +1985,46 @@ fn compare_impl_const<'tcx>(
trait_const_item: ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorGuaranteed> {
compare_type_const(tcx, impl_const_item, trait_const_item)?;
compare_number_of_generics(tcx, impl_const_item, trait_const_item, false)?;
compare_generic_param_kinds(tcx, impl_const_item, trait_const_item, false)?;
check_region_bounds_on_impl_item(tcx, impl_const_item, trait_const_item, false)?;
compare_const_predicate_entailment(tcx, impl_const_item, trait_const_item, impl_trait_ref)
}

fn compare_type_const<'tcx>(
tcx: TyCtxt<'tcx>,
impl_const_item: ty::AssocItem,
trait_const_item: ty::AssocItem,
) -> Result<(), ErrorGuaranteed> {
let impl_is_type_const =
find_attr!(tcx.get_all_attrs(impl_const_item.def_id), AttributeKind::TypeConst(_));
let trait_type_const_span = find_attr!(
tcx.get_all_attrs(trait_const_item.def_id),
AttributeKind::TypeConst(sp) => *sp
);

if let Some(trait_type_const_span) = trait_type_const_span
&& !impl_is_type_const
{
return Err(tcx
.dcx()
.struct_span_err(
tcx.def_span(impl_const_item.def_id),
"implementation of `#[type_const]` const must be marked with `#[type_const]`",
)
.with_span_note(
MultiSpan::from_spans(vec![
tcx.def_span(trait_const_item.def_id),
trait_type_const_span,
]),
"trait declaration of const is marked with `#[type_const]`",
)
.emit());
}
Ok(())
}

/// The equivalent of [compare_method_predicate_entailment], but for associated constants
/// instead of associated functions.
// FIXME(generic_const_items): If possible extract the common parts of `compare_{type,const}_predicate_entailment`.
Expand Down
Loading
Loading