Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6b30d83
Lower #[no_mangle] to #[symbol_name]/#[link_name]
bjorn3 Jul 15, 2026
f141419
Fix clashing_extern_declarations lint
bjorn3 Jul 16, 2026
4d5eb58
Bless several tests
bjorn3 Jul 16, 2026
23a3f18
Disable symbol name mangling for #[link_ordinal]
bjorn3 Jul 16, 2026
3bc2932
Add explanation why #[no_mangle] + #[link_name] matters
bjorn3 Aug 20, 2026
2c2e988
Clarify comment
bjorn3 Oct 9, 2026
d79c109
Apply comment wording suggestions by Ralf
bjorn3 Oct 9, 2026
11a8eaf
Accept variadic SysV64, Win64, and Aapcs FnAbis in rustc_public
lapla-cogito Nov 3, 2026
460bb55
Review comments
bjorn3 Nov 3, 2026
b4b982c
Use symbol name in build_dll_import
bjorn3 Nov 5, 2026
4400802
fallible type ops
nia-e Jun 15, 2026
a51b14a
Use the `2.38` binutils version in CI
GuillaumeGomez Oct 28, 2026
70ed043
update Enzyem submodule
ZuseZ4 Nov 5, 2026
1dd187d
Update Vec::retain_unstable docs to say that this method is generally…
asder8215 Nov 4, 2026
d40c05a
DFV: Reject `#[non_exhaustive]` on enum variants with default field v…
fmease Nov 5, 2026
8696003
remove unused WhereEqPredicate and ScopeId types
TaKO8Ki Nov 5, 2026
7f4b36e
When missing const param in `impl`, provide complete suggestion
estebank Oct 23, 2026
8718bb4
Point at const param declaration when constant is not expected type
estebank Oct 23, 2026
37d1642
Point at type alias type on failed obligations
estebank Oct 23, 2026
1be208e
Tweak span of WF errors in type aliases
estebank Oct 23, 2026
3fceff3
Reword label
estebank Nov 4, 2026
dc7eb41
style-guide: Remove ABI explicitness prescription for extern items
GrimlockOnline Nov 5, 2026
64fe271
Update books
rustbot Nov 5, 2026
39cd593
Disable MAKEINFO when building binutils
GuillaumeGomez Oct 28, 2026
266b16c
Bump SCCACHE_C_CUSTOM_CACHE_BUSTER to force sccache refresh
GuillaumeGomez Nov 5, 2026
b4f8df1
Fix suggestion span
estebank Nov 5, 2026
ca9e035
Fix rebase
estebank Nov 5, 2026
af6c6bc
Update CI GCC stamp
GuillaumeGomez Nov 5, 2026
2aa9a63
Improve comment
GuillaumeGomez Nov 5, 2026
db777f2
Fix warnings for the L4Re targets
farao Nov 5, 2026
c08c7c6
Anonymize all binders and bound vars
mu001999 Oct 31, 2026
018a26a
Rollup merge of #165078 - GuillaumeGomez:binutils-2.38, r=Kobzol
JonathanBrouwer Nov 6, 2026
e73d8ce
Rollup merge of #159374 - bjorn3:desugar_no_mangle, r=mejrs
JonathanBrouwer Nov 6, 2026
aed60e2
Rollup merge of #164775 - estebank:missing-const-param, r=wesleywiser
JonathanBrouwer Nov 6, 2026
ce56425
Rollup merge of #165222 - mu001999-contrib:fix-165091, r=fmease
JonathanBrouwer Nov 6, 2026
941c8ad
Rollup merge of #165335 - jdonszelmann:fallible-type-ops, r=adwinwhite
JonathanBrouwer Nov 6, 2026
b605a6b
Rollup merge of #165388 - lapla-cogito:issue_163233, r=makai410
JonathanBrouwer Nov 6, 2026
15bdf02
Rollup merge of #165448 - asder8215:vec_retain_unstable_docs, r=maxdexh
JonathanBrouwer Nov 6, 2026
b13362c
Rollup merge of #165503 - ZuseZ4:update-enzyme-05-11, r=ZuseZ4
JonathanBrouwer Nov 6, 2026
983e5ad
Rollup merge of #165505 - fmease:dfv-rej-nonex-struct-like-variant, r…
JonathanBrouwer Nov 6, 2026
69dcb70
Rollup merge of #165512 - farao:l4re-fix-build2, r=maxdexh
JonathanBrouwer Nov 6, 2026
54c5771
Rollup merge of #165514 - TaKO8Ki:remove-unused-predicate-and-scope-t…
JonathanBrouwer Nov 6, 2026
e95be04
Rollup merge of #165518 - Kolgrim33:style-guide-remove-abi-prescripti…
JonathanBrouwer Nov 6, 2026
060cefa
Rollup merge of #165519 - rustbot:docs-update, r=traviscross
JonathanBrouwer Nov 6, 2026
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
9 changes: 0 additions & 9 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,6 @@ pub struct WhereRegionPredicate {
pub bounds: GenericBounds,
}

/// An equality predicate (unsupported).
///
/// E.g., `T = int`.
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct WhereEqPredicate {
pub lhs_ty: Box<Ty>,
pub rhs_ty: Box<Ty>,
}

#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct Crate {
/// Must be equal to `CRATE_NODE_ID` after the crate root is expanded, but may hold
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ macro_rules! common_visitor_and_walkers {
VisibilityKind,
WhereBoundPredicate,
WhereClause,
WhereEqPredicate,
WhereRegionPredicate,
YieldKind,
// tidy-alphabetical-end
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ impl NoArgsAttributeParser for NonExhaustiveParser {
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;

fn finalize_check(cx: &mut FinalizeCheckContext<'_, '_>, attr_span: Span) {
let AstTarget::Struct(_, _, data) = cx.ast_target else {
return;
};
if let VariantData::Struct { fields, .. } = data
if let AstTarget::Struct(_, _, data) | AstTarget::Variant(rustc_ast::Variant { data, .. }) =
cx.ast_target
&& let VariantData::Struct { fields, .. } = data
&& fields.iter().any(|f| f.default_value().is_some())
{
cx.emit_err(NonExhaustiveWithDefaultFieldValues {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ pub(crate) struct DeprecatedAnnotationHasNoEffect {
}

#[derive(Diagnostic)]
#[diag("`#[non_exhaustive]` can't be used to annotate items with default field values")]
#[diag("`#[non_exhaustive]` can't be used to annotate structs with default field values")]
pub(crate) struct NonExhaustiveWithDefaultFieldValues {
#[primary_span]
pub attr_span: Span,
Expand Down
36 changes: 36 additions & 0 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use std::fmt;
use rustc_errors::ErrorGuaranteed;
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::traits::Obligation;
use rustc_middle::mir::{Body, ConstraintCategory};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Unnormalized, Upcast};
use rustc_span::def_id::DefId;
use rustc_span::{Span, bug};
use rustc_trait_selection::traits::ObligationCause;
use rustc_trait_selection::traits::query::type_op::custom::FallibleCustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
use tracing::{debug, instrument};

Expand Down Expand Up @@ -165,6 +167,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}

/// Proves and asserts that a predicate holds.
/// Errors may be emitted that are only dependent on region constraints.
/// However, errors that are not dependent on region constraints are emitted as a delayed bug,
/// since those should have already been emitted earlier in the compiler.
/// If this is undesirable and errors should be emitted properly,
/// use [`prove_fallible_predicate`](Self::prove_fallible_predicate).
#[instrument(skip(self), level = "debug")]
pub(super) fn prove_clause(
&mut self,
Expand All @@ -182,6 +190,34 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
);
}

/// Certain proofs (e.g. `Move`) may error during MIR typeck for reasons that
/// are unrelated to regions. Unlike [`prove_clause`](Self::prove_clause),
/// this API reports those errors properly.
#[allow(unused)]
pub(super) fn prove_fallible_predicate(
&mut self,
predicate: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + std::fmt::Debug,
locations: Locations,
category: ConstraintCategory<'tcx>,
) {
let span = self.last_span;
let predicate = predicate.upcast(self.tcx());
let op = FallibleCustomTypeOp::new(
|ocx| {
ocx.register_obligation(Obligation::new(
ocx.infcx.tcx,
ObligationCause::dummy_with_span(span),
self.infcx.param_env,
predicate,
));
Ok(())
},
"fallible type op",
);

let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(locations, category, op);
}

pub(super) fn normalize<T>(
&mut self,
value: Unnormalized<'tcx, T>,
Expand Down
16 changes: 11 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_infer::infer::region_constraints::RegionConstraintData;
use rustc_infer::infer::{
BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin,
};
use rustc_infer::traits::{Obligation, ObligationCause, PredicateObligations};
use rustc_infer::traits::{Obligation, ObligationCause, PredicateObligations, ScrubbedTraitError};
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::*;
use rustc_middle::traits::query::NoSolution;
Expand Down Expand Up @@ -2800,10 +2800,16 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
span: Span,
) -> Result<TypeOpOutput<'tcx, Self>, ErrorGuaranteed> {
let (mut output, region_constraints) =
scrape_region_constraints(infcx, root_def_id, "InstantiateOpaqueType", span, |ocx| {
ocx.register_obligations(self.obligations.clone());
Ok(())
})?;
scrape_region_constraints::<_, _, ScrubbedTraitError<'tcx>>(
infcx,
root_def_id,
"InstantiateOpaqueType",
span,
|ocx| {
ocx.register_obligations(self.obligations.clone());
Ok(())
},
)?;
self.region_constraints = Some(region_constraints);
output.error_info = Some(self);
Ok(output)
Expand Down
46 changes: 35 additions & 11 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,19 @@ fn process_builtin_attrs(
AttributeKind::LinkSection { name } => codegen_fn_attrs.link_section = Some(*name),
AttributeKind::NoMangle(attr_span) => {
interesting_spans.no_mangle = Some(*attr_span);
if tcx.opt_item_name(did.to_def_id()).is_some() {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
if let Some(name) = tcx.opt_item_name(did.to_def_id()) {
// Don't override #[export_name].

// Also don't override #[link_name]. All places where #[link_name] is allowed
// shouldn't allow #[no_mangle], so #[link_name] shouldn't be a concern here,
// however currently #[no_mangle] is currently merely a warning on foreign
// items rather than a hard error, so we still need to take #[no_mangle] +
// #[link_name] into account.
// FIXME remove this comment once #[no_mangle] on foreign items is a hard error.

if codegen_fn_attrs.symbol_name.is_none() {
codegen_fn_attrs.symbol_name = Some(name);
}
} else {
tcx.dcx()
.span_delayed_bug(*attr_span, "no_mangle should be on a named function");
Expand Down Expand Up @@ -429,6 +440,8 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code
}

// Foreign items by default use no mangling for their symbol name.
// Usually, `symbol_name` is controlled by `#[link_name]`/`#[export_name]`. Here we additionally
// set `symbol_name` on most foreign items so that their their symbol name does not get mangled.
if tcx.is_foreign_item(did) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FOREIGN_ITEM;

Expand All @@ -444,16 +457,21 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code
// Implementing an EII does the appropriate name resolution to make sure the implementations
// get the same symbol name as the *mangled* foreign item they refer to so that's all good.
} else if codegen_fn_attrs.symbol_name.is_some() {
// * This can be overridden with the `#[link_name]` attribute
// * If the name is already set by `#[link_name]`, we don't overwrite it.
} else if codegen_fn_attrs.link_ordinal.is_some() {
// * `#[link_ordinal]` and `#[link_name]` are incompatible with each other, so
// disable the implicit `#[link_name]` for foreign items below to avoid an
// error.
} else {
// This effectively adds an implicit `#[link_name = "<item name>"]`.
// NOTE: there's one more exception that we cannot apply here. On wasm,
// some items cannot be `no_mangle`.
// However, we don't have enough information here to determine that.
// As such, no_mangle foreign items on wasm that have the same defid as some
// import will *still* be mangled despite this.
//
// if none of the exceptions apply; apply no_mangle
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
// if none of the exceptions apply; do not mangle the symbol name
codegen_fn_attrs.symbol_name = Some(tcx.item_name(did));
}
}
}
Expand Down Expand Up @@ -552,22 +570,24 @@ fn handle_lang_items(
// strippable by the linker.
//
// Additionally weak lang items have predetermined symbol names.
if let Some(lang_item) = lang_item
let link_name_override = if let Some(lang_item) = lang_item
&& let Some(link_name) = lang_item.link_name()
{
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
codegen_fn_attrs.symbol_name = Some(link_name);
}
Some(link_name)
} else {
None
};

// error when using no_mangle on a lang item item
// error when using no_mangle, or export_name on a lang item item
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
&& codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE)
&& codegen_fn_attrs.symbol_name.is_some()
{
let mut err = tcx
.dcx()
.struct_span_err(
interesting_spans.no_mangle.unwrap_or_default(),
"`#[no_mangle]` cannot be used on internal language items",
"`#[no_mangle]` and `#[export_name]` cannot be used on internal language items",
)
.with_note("Rustc requires this item to have a specific mangled name.")
.with_span_label(tcx.def_span(did), "should be the internal language item");
Expand All @@ -583,6 +603,10 @@ fn handle_lang_items(
}
err.emit();
}

if let Some(link_name_override) = link_name_override {
codegen_fn_attrs.symbol_name = Some(link_name_override);
}
}

/// Generate the [`CodegenFnAttrs`] for an item (identified by the [`LocalDefId`]).
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,13 +1280,6 @@ impl<'hir> WhereRegionPredicate<'hir> {
}
}

/// An equality predicate (e.g., `T = int`); currently unsupported.
#[derive(Debug, Clone, Copy, StableHash)]
pub struct WhereEqPredicate<'hir> {
pub lhs_ty: &'hir Ty<'hir>,
pub rhs_ty: &'hir Ty<'hir>,
}

/// HIR node coupled with its parent's id in the same HIR owner.
///
/// The parent is trash when the node is a HIR owner.
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,11 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().clauses_of(def_id);
let ty = tcx.type_of(def_id).instantiate_identity();
let span = tcx.def_span(def_id);
let span = match tcx.hir_node_by_def_id(def_id).alias_ty() {
Some(ty) => ty.span,
_ => tcx.def_span(def_id),
};

if tcx.type_alias_is_checked(def_id) {
res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
let item_ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty);
Expand Down
57 changes: 50 additions & 7 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_types_for_signature};
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable,
TypeVisitableExt, TypeVisitor, TypingMode, Unnormalized,
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable,
TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Unnormalized,
};
use rustc_span::def_id::ModId;
use rustc_span::{Span, span_bug};
Expand Down Expand Up @@ -210,8 +210,8 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
// Also, We have to anonymize binders in these types because they may contain
// `BrNamed` bound vars, which contain unique `DefId`s which correspond to syntax
// locations that we don't care about when checking bound equality.
let trait_bounds = FxIndexSet::from_iter(trait_bounds.fold_with(&mut Anonymize { tcx }));
let impl_bounds = impl_bounds.fold_with(&mut Anonymize { tcx });
let trait_bounds = FxIndexSet::from_iter(trait_bounds.fold_with(&mut FullyAnonymize { tcx }));
let impl_bounds = impl_bounds.fold_with(&mut FullyAnonymize { tcx });

// Find any clauses that are present in the impl's RPITITs that are not
// present in the trait's RPITITs. This will trigger on trivial predicates,
Expand Down Expand Up @@ -415,11 +415,13 @@ fn type_visibility<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<ty::Visibili
}
}

struct Anonymize<'tcx> {
/// Contrary to [`TyCtxt::anonymize_bound_vars`] this anonymizes *all* binders and bound vars,
/// not just the `Binder` and its bound vars that was provided as an argument.
struct FullyAnonymize<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for FullyAnonymize<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}
Expand All @@ -428,7 +430,48 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
self.tcx.anonymize_bound_vars(t)
let bound_vars = self.tcx.mk_bound_variable_kinds_from_iter(t.bound_vars().iter().map(
|kind| match kind {
ty::BoundVariableKind::Ty(_) => ty::BoundVariableKind::Ty(ty::BoundTyKind::Anon),
ty::BoundVariableKind::Region(_) => {
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)
}
ty::BoundVariableKind::Const => ty::BoundVariableKind::Const,
},
));
ty::Binder::bind_with_vars(t.skip_binder().fold_with(self), bound_vars)
}

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
if let ty::RegionKind::ReBound(ty::BoundVarIndexKind::Bound(debruijn), bound_re) = r.kind()
{
ty::Region::new_anon_bound(self.tcx, debruijn, bound_re.var)
} else {
r
}
}

fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
if !t.has_bound_vars() {
return t;
}
if let ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_ty) = *t.kind() {
let bound_ty = ty::BoundTy { var: bound_ty.var, kind: ty::BoundTyKind::Anon };
Ty::new_bound(self.tcx, debruijn, bound_ty)
} else {
t.super_fold_with(self)
}
}

fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
if !c.has_bound_vars() {
return c;
}
if let ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_ct) = c.kind() {
ty::Const::new_anon_bound(self.tcx, debruijn, bound_ct.var)
} else {
c.super_fold_with(self)
}
}
}

Expand Down
Loading
Loading