Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
58ef104
Distinguish `repr(C)` ZSTs from others in ABI computation
Jules-Bertholet Oct 2, 2026
a9b9130
Fix comment
Jules-Bertholet Oct 3, 2026
9c51f25
fix typo
Jules-Bertholet Oct 3, 2026
9ce47de
explicitly check for fresh vars in canonicalize
lcnr Oct 6, 2026
7c69454
Don't add rustc to env in nix dev shell
maxdexh Oct 6, 2026
381a3bd
Add a test case
saethlin Oct 6, 2026
f5733a7
Fix by checking offset is a multiple of align
saethlin Oct 6, 2026
cb35723
Remove `NonOwner` variant from `AstOwner`
aerooneqq Oct 6, 2026
308801e
Panic on `StableHash` of a `Path` with `GenericArgs`
joshtriplett Oct 6, 2026
3d0abf0
Remove needless closure in bootstrap
Jules-Bertholet Oct 6, 2026
879c65a
Clean up Reference annotations that drifted
traviscross Aug 28, 2026
95811cf
Rename a test file
Jules-Bertholet Oct 6, 2026
9a6d547
Update Enzyme submodule
ZuseZ4 Oct 6, 2026
e5ebfd8
[PAC] Stop hard coding key and discriminator, consult schema instead
jchlanda Oct 2, 2026
5040ebc
abby DSL: implement ambiguity
khyperia Oct 7, 2026
23be578
Submodule update of rustc-perf
Kobzol Oct 7, 2026
f8e6f1c
Rollup merge of #156112 - Jules-Bertholet:distinguish-c-zsts, r=oli-obk
JonathanBrouwer Oct 7, 2026
75ae01c
Rollup merge of #163887 - aerooneqq:remove-ast-non-owner, r=joshtriplett
JonathanBrouwer Oct 7, 2026
261364a
Rollup merge of #163925 - Kobzol:rustc-perf-update, r=lqd
JonathanBrouwer Oct 7, 2026
cdde72e
Rollup merge of #163658 - jchlanda:jakub/key_disc_fix, r=nnethercote
JonathanBrouwer Oct 7, 2026
08f0539
Rollup merge of #163854 - saethlin:gvn-intern-alignment, r=oli-obk
JonathanBrouwer Oct 7, 2026
e7611f5
Rollup merge of #163874 - lcnr:ice-on-fresh-vars, r=oli-obk
JonathanBrouwer Oct 7, 2026
b4de748
Rollup merge of #163880 - maxdexh:dont-pollute-path, r=clubby789
JonathanBrouwer Oct 7, 2026
cc7c005
Rollup merge of #163893 - joshtriplett:ast-path-hash-args, r=nnethercote
JonathanBrouwer Oct 7, 2026
83ff72a
Rollup merge of #163902 - traviscross:TC/add-reference-annotations_cl…
JonathanBrouwer Oct 7, 2026
92b4936
Rollup merge of #163905 - Jules-Bertholet:bootstrap-tweak, r=Kobzol
JonathanBrouwer Oct 7, 2026
0a7512f
Rollup merge of #163908 - ZuseZ4:update-enzyme-oct-06-2026, r=ZuseZ4
JonathanBrouwer Oct 7, 2026
b7506a3
Rollup merge of #163921 - khyperia:abby-dsl-ambiguity, r=BoxyUwU
JonathanBrouwer Oct 7, 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
13 changes: 13 additions & 0 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align: None,
unadjusted_abi_align: element.align.abi,
repr_c: element.repr_c,
randomization_seed: element.randomization_seed.wrapping_add(Hash64::new(count)),
})
}
Expand Down Expand Up @@ -501,6 +502,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
return Err(LayoutCalculatorError::EmptyUnion);
};

// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
let repr_c =
repr.c() || (repr.transparent() && only_variant.iter().any(|field| field.repr_c));

let combined_seed = only_variant
.iter()
.map(|v| v.randomization_seed)
Expand All @@ -516,6 +521,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size: size.align_to(align),
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed: combined_seed,
})
}
Expand Down Expand Up @@ -747,6 +753,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
align: AbiAlign::new(align),
max_repr_align,
unadjusted_abi_align,
repr_c: repr.c(),
randomization_seed: combined_seed,
};

Expand Down Expand Up @@ -1055,6 +1062,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align,
unadjusted_abi_align,
repr_c: repr.c(),
randomization_seed: combined_seed,
};

Expand Down Expand Up @@ -1409,6 +1417,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
unadjusted_abi_align
};

// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
let repr_c = repr.c() || (repr.transparent() && fields.iter().any(|field| field.repr_c));

let seed = field_seed.wrapping_add(repr.field_shuffle_seed);

Ok(LayoutData {
Expand All @@ -1421,6 +1432,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed: seed,
})
}
Expand Down Expand Up @@ -1519,6 +1531,7 @@ where
align: AbiAlign::new(align),
max_repr_align: None,
unadjusted_abi_align: elt.align.abi,
repr_c: false,
randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count.as_u64())),
})
}
1 change: 1 addition & 0 deletions compiler/rustc_abi/src/layout/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ where
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
repr_c: false,
randomization_seed: Default::default(),
})
}
6 changes: 6 additions & 0 deletions compiler/rustc_abi/src/layout/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
randomization_seed: Hash64::new(0),
}
}
Expand All @@ -42,6 +43,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
randomization_seed: Hash64::ZERO,
}
}
Expand Down Expand Up @@ -84,6 +86,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
repr_c: false,
randomization_seed: Hash64::new(randomization_seed),
}
}
Expand Down Expand Up @@ -117,6 +120,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size,
max_repr_align: None,
unadjusted_abi_align: align,
repr_c: false,
randomization_seed: Hash64::new(combined_seed),
}
}
Expand All @@ -143,6 +147,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
// Variant layouts never flow back into actual layout computations,
// so dummy values are fine here.
randomization_seed: Hash64::ZERO,
Expand All @@ -169,6 +174,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
align: parent.align,
max_repr_align: parent.max_repr_align,
unadjusted_abi_align: parent.unadjusted_abi_align,
repr_c: parent.repr_c,
// Variant layouts never flow back into actual layout computations,
// so dummy values are fine here.
randomization_seed: Hash64::ZERO,
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,13 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// alignment in some cases.
pub unadjusted_abi_align: Align,

/// Whether this type is `repr(C)`, or a `repr(transparent)` wrapper around such,
/// or an array of such.
/// This matters because we must follow the C ABI for these types.
/// Some C ABIs pass `repr(C)` ZSTs by pointer, but `repr(Rust)` ZSTs should always
/// be ignored.
pub repr_c: bool,

/// The randomization seed based on this type's own repr and its fields.
///
/// Since randomization is toggled on a per-crate basis even crates that do not have randomization
Expand Down Expand Up @@ -2293,6 +2300,12 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
}
}
}

/// Returns `true` if this is a `repr(C)` type,
/// or an array of such, or a `repr(transparent)` wrapper around such
pub fn is_repr_c(&self) -> bool {
self.repr_c
}
}

impl<FieldIdx: Idx, VariantIdx: Idx> fmt::Debug for LayoutData<FieldIdx, VariantIdx>
Expand All @@ -2314,6 +2327,7 @@ where
variants,
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed,
} = self;
f.debug_struct("Layout")
Expand All @@ -2326,6 +2340,7 @@ where
.field("variants", variants)
.field("max_repr_align", max_repr_align)
.field("unadjusted_abi_align", unadjusted_abi_align)
.field("repr_c", repr_c)
.field("randomization_seed", randomization_seed)
.finish()
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ impl StableHash for Path {
self.segments.len().stable_hash(hcx, hasher);
for segment in &self.segments {
segment.ident.stable_hash(hcx, hasher);
if segment.args.is_some() {
// This should never happen, because Path::stable_hash is only used for attributes,
// which never have generic args. Check that to make sure, though.
panic!("Paths with generic args should not appear in incremental state");
}
}
}
}
Expand Down Expand Up @@ -4100,6 +4105,9 @@ pub enum TestBinderConstraint {
Or {
items: ThinVec<TestBinderConstraint>,
},
Ambiguity {
span: Span,
},
Lifetime {
#[visitable(extra = LifetimeCtxt::Bound)]
lhs: Lifetime,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/delegation/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use ast::visit::Visitor;
use hir::def::DefKind;
use rustc_ast::{self as ast, AssocItemKind, Delegation, DelegationSource, Item, ItemKind, NodeId};
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::steal::Steal;
use rustc_hir as hir;
use rustc_middle::middle::resolve::{
self as mid_res, AstOwner, DelegationInherentFnKind, TypeRelativeDelegationRes,
Expand Down Expand Up @@ -53,9 +52,10 @@ pub(crate) fn resolve_type_relative_delegations(
// Also record resolutions for cases when signature is resolved but call path is not.
mid_res::DelegationResolution::Partial
| mid_res::DelegationResolution::PartialCall(_) => {
let Some(r_and_owner) = ast_index.get(def_id).map(Steal::borrow) else {
unreachable!("ast index must contain delegations");
};
let r_and_owner = ast_index[def_id]
.as_ref()
.expect("ast index must contain delegations")
.borrow();

let (r, owner) = &*r_and_owner;

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
items.iter().map(|item| self.lower_test_binder_constraint(item)),
),
},
TestBinderConstraint::Ambiguity { span } => {
hir::TestBinderConstraint::Ambiguity { span: self.lower_span(*span) }
}
TestBinderConstraint::Lifetime { lhs, rhs } => {
let lhs = self.lower_lifetime(lhs, LifetimeSource::Other, lhs.ident.into());
let rhs = self.lower_lifetime(rhs, LifetimeSource::OutlivesBound, rhs.ident.into());
Expand Down
21 changes: 11 additions & 10 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ enum TryBlockScope {
fn index_ast<'tcx>(
tcx: TyCtxt<'tcx>,
(): (),
) -> &'tcx IndexSlice<LocalDefId, Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>> {
) -> &'tcx IndexSlice<LocalDefId, Option<Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>>> {
// Queries that borrow `resolver_for_lowering`.
tcx.ensure_done().output_filenames(());
tcx.ensure_done().early_lint_checks(());
Expand All @@ -610,20 +610,19 @@ fn index_ast<'tcx>(
let index = indexer.index;
let resolver = Arc::new(resolver);
return tcx.arena.alloc_index_slice_from_iter::<LocalDefId, _, _>(
index.into_iter().map(|owner| Steal::new((Arc::clone(&resolver), owner))),
index.into_iter().map(|owner| owner.map(|o| Steal::new((Arc::clone(&resolver), o)))),
);

struct Indexer<'s, 'hir> {
owners: &'s NodeMap<PerOwnerResolverData<'hir>>,
index: IndexVec<LocalDefId, AstOwner>,
index: IndexVec<LocalDefId, Option<AstOwner>>,
next_node_id: NodeId,
}

impl Indexer<'_, '_> {
fn insert(&mut self, id: NodeId, node: AstOwner) {
let def_id = self.owners[&id].def_id;
self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner);
self.index[def_id] = node;
self.index.insert(def_id, node);
}

fn make_dummy<K>(
Expand Down Expand Up @@ -705,7 +704,7 @@ fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
tcx.ensure_done().resolve_type_relative_delegations(());

let ast_index = tcx.index_ast(());
let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
let resolver_and_node = ast_index.get(def_id);

let fallback_to_ancestor = || {
// The item did not exist in the AST, it was created while lowering another item.
Expand All @@ -732,10 +731,13 @@ fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
})
};

let Some((resolver, node)) = resolver_and_node else {
let Some(Some(r_and_node)) = resolver_and_node else {
// `ast_index` does not contain all definitions, only up-to the highest
// `LocalDefId` which has a non-trivial `AstOwner`. Gracefully handle
// other definitions, in particular those nested inside this highest definition.
// OR
// The item existed in the AST, but is not a HIR owner.
// Fetch the correct information from its parent.
return fallback_to_ancestor();
};

Expand All @@ -750,6 +752,8 @@ fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx, item))
}

let (resolver, node) = r_and_node.steal();

let item = match &node {
// The item existed in the AST.
AstOwner::Crate(c) => with_lctx(tcx, &*resolver, CRATE_NODE_ID, |lctx| {
Expand All @@ -770,9 +774,6 @@ fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
AstOwner::ForeignItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
}),
// The item existed in the AST, but is not a HIR owner.
// Fetch the correct information from its parent.
AstOwner::NonOwner => fallback_to_ancestor(),
};

tcx.sess.time("drop_ast", || mem::drop(node));
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,8 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
llfn: &'ll Value,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
) -> Option<llvm::OperandBundleBox<'ll>> {
if self.sess().pointer_authentication_functions().is_none() {
return None;
}
let schema = self.sess().pointer_authentication_functions()?;

// Pointer authentication support is currently limited to extern "C" calls; filter out other
// ABIs.
if fn_abi?.conv != CanonAbi::C {
Expand All @@ -2207,11 +2206,12 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
// bundles.
// Once this is resolved, we should analyze each call and skip direct calls. See the
// discussion in the rust-lang issue: <https://github.com/rust-lang/rust/issues/152532>
let key: u32 = 0;
let discriminator: u64 = 0;
Some(llvm::OperandBundleBox::new(
"ptrauth",
&[self.const_u32(key), self.const_u64(discriminator)],
&[
self.const_u32(schema.key as u32),
self.const_u64(schema.constant_discriminator as u64),
],
))
}

Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn check_and_apply_linkage<'ll, 'tcx>(
let fn_sig = sig.with(*header);
let fn_abi = cx.fn_abi_of_fn_ptr(fn_sig, ty::List::empty());
// Decide if the initializer needs to be signed
if cx.sess().pointer_authentication()
if cx.sess().pointer_authentication_functions().is_some()
&& matches!(fn_sig.abi(), ExternAbi::C { .. } | ExternAbi::System { .. })
{
should_sign = true;
Expand Down Expand Up @@ -249,13 +249,16 @@ fn check_and_apply_linkage<'ll, 'tcx>(

// Sign the function pointer that is used to initialize the global
let initializer = if should_sign {
let key: u32 = 0;
let discriminator: u64 = 0;
let schema = cx
.tcx
.sess
.pointer_authentication_functions()
.expect("pointer authentication functions must be available when signing");

const_ptr_auth(
cx.const_bitcast(g1, llty),
key,
discriminator,
schema.key as u32,
schema.constant_discriminator as u64,
None, /* address_diversity */
)
} else {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4556,6 +4556,7 @@ pub struct TestBinderExists<'hir> {
pub enum TestBinderConstraint<'hir> {
And { items: &'hir [TestBinderConstraint<'hir>] },
Or { items: &'hir [TestBinderConstraint<'hir>] },
Ambiguity { span: Span },
Lifetime { lhs: &'hir Lifetime, rhs: &'hir Lifetime },
PlaceholderOutlives { lhs: &'hir Ty<'hir>, rhs: &'hir Lifetime },
AliasOutlives { bound_type_constraint: &'hir TestBinderBoundTypeConstraint<'hir> },
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@ pub fn walk_test_binder_constraint<'v, V: Visitor<'v>>(
TestBinderConstraint::Or { items } => {
walk_list!(visitor, visit_test_binder_constraint, *items)
}
TestBinderConstraint::Ambiguity { span: _ } => {}
TestBinderConstraint::Lifetime { lhs, rhs } => {
try_visit!(visitor.visit_lifetime(lhs));
try_visit!(visitor.visit_lifetime(rhs));
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ impl<'tcx> ItemCtxt<'tcx> {
.map(|item| self.lower_test_binder_constraint(item))
.reduce(SolverRegionConstraint::build_or)
.unwrap_or(SolverRegionConstraint::new_false()),
rustc_hir::TestBinderConstraint::Ambiguity { span } => {
SolverRegionConstraint::new_ambig(*span)
}
hir::TestBinderConstraint::Lifetime { lhs, rhs } => {
let span = lhs.ident.span.to(rhs.ident.span);
let lhs = self.lowerer().lower_lifetime(lhs, RegionInferReason::RegionPredicate);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ rustc_arena::declare_arena! {
rustc_middle::middle::resolve::ResolverAstLowering<'tcx>
>,
index_ast:
rustc_data_structures::steal::Steal<(
Option<rustc_data_structures::steal::Steal<(
std::sync::Arc<rustc_middle::middle::resolve::ResolverAstLowering<'tcx>>,
rustc_middle::middle::resolve::AstOwner
)>,
)>>,
crate_alone: rustc_data_structures::steal::Steal<rustc_ast::Crate>,
crate_for_resolver: rustc_data_structures::steal::Steal<(rustc_ast::Crate, rustc_ast::AttrVec)>,
resolutions: rustc_middle::middle::resolve::ResolverGlobalCtxt,
Expand Down
Loading
Loading