Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5fbbf47
std: Use getexecpath() for current_exe() on OpenBSD
brad0 Oct 15, 2026
09026e0
avoid building a region map when erasing bound regions
TaKO8Ki Oct 29, 2026
380fd0d
Reuse CanonicalVarKinds if no new variables were added
Randl Nov 2, 2026
bec2190
inline and cold attributes on async fn and async closures affect the …
xacrimon Sep 26, 2026
1c517b2
Don't keep #[rustc_force_inline] on async/gen fn constructors
xacrimon Nov 2, 2026
2caedab
Adapt async fn inline attrs to #[inline(always)] + #[target_feature] …
xacrimon Nov 2, 2026
a8c4be1
Replace `AbiAlign` with `Align` in `LayoutData`
beetrees Nov 2, 2026
7f36744
Remove `AbiAlign`
beetrees Nov 2, 2026
9b1ceff
Reenable the cg_gcc tests that were disabled by accident
antoyo Nov 2, 2026
86fd101
rename sizedness_fast_path to implicit_fast_path
jdonszelmann Nov 2, 2026
1b8ce17
refactor implicit bounds addition
jdonszelmann Nov 2, 2026
7eb4e44
Implement AIX TLS destructor guard in std and update dynamic-loading-…
xingxue-ibm Oct 30, 2026
f0767bb
add is_implicit_trait to tcx
jdonszelmann Nov 2, 2026
aff3637
Don't use `llvm_type` as the type of `static`s.
beetrees Nov 2, 2026
79520af
Avoid oscillating line wrapping due to symbol indices
aytey Sep 10, 2026
be89a22
Replace `builtin # field_of` with `k#field_of`
fmease Sep 3, 2026
f2f5592
Replace `builtin # deref` with `k#deref`
fmease Sep 3, 2026
c9e0b0a
Replace `builtin # offset_of` with `k#offset_of`
fmease Sep 3, 2026
be1070c
Replace `builtin # type_ascribe` with `k#type_ascribe`
fmease Sep 3, 2026
ee888ba
Replace `builtin # {,un}wrap_binder` with `k#{,un}wrap_binder`
fmease Sep 3, 2026
2a9fdf5
Rename feature `builtin_syntax` to `internal_syntax`
fmease Sep 3, 2026
a72068e
Fix rigidity assertion ICE
lsunsi Nov 3, 2026
e083b8b
offload: pass the linked device image to the host pass
sgasho Oct 24, 2026
b76246d
offload: make the device build work without `--emit=llvm-bc`/`llvm-ir`
sgasho Oct 25, 2026
c6749d8
offload: build bin crates as cdylib on the device side
sgasho Oct 29, 2026
dedfa67
Make `ExpectedLint` more general
JonathanBrouwer Oct 26, 2026
58c0988
Use `ExpectedLint` in more places
JonathanBrouwer Oct 27, 2026
cdc3205
Make diagnostic title consistent with other attributes
JonathanBrouwer Nov 3, 2026
6359465
Rollup merge of #149245 - xacrimon:acrimon/async-fn-inline-attr, r=sa…
JonathanBrouwer Nov 3, 2026
2993e5a
Rollup merge of #164304 - Randl:perf-reuse, r=ShoyuVanilla
JonathanBrouwer Nov 3, 2026
95414a5
Rollup merge of #165109 - TaKO8Ki:avoid-erased-region-map, r=lcnr
JonathanBrouwer Nov 3, 2026
6d9ffeb
Rollup merge of #163393 - brad0:std_src_sys_paths_unix, r=JohnTitor
JonathanBrouwer Nov 3, 2026
f3687f2
Rollup merge of #164896 - sgasho:offload-cleanup-2, r=ZuseZ4
JonathanBrouwer Nov 3, 2026
b13c6fa
Rollup merge of #165358 - antoyo:fix/reenable-cg_gcc-tests, r=Guillau…
JonathanBrouwer Nov 3, 2026
25d4ea1
Rollup merge of #165371 - beetrees:global-llvm-type, r=folkertdev
JonathanBrouwer Nov 3, 2026
754474b
Rollup merge of #162232 - fmease:yeet-builtin-hash, r=JohnTitor
JonathanBrouwer Nov 3, 2026
2863f1e
Rollup merge of #162608 - aytey:unpretty-hygiene-test-churn, r=fmease
JonathanBrouwer Nov 3, 2026
d2fb2fc
Rollup merge of #165029 - JonathanBrouwer:expected-lint, r=fmease
JonathanBrouwer Nov 3, 2026
3eb45a4
Rollup merge of #165203 - xingxue-ibm:aix-disable-test-dynamic-loadin…
JonathanBrouwer Nov 3, 2026
4f8e3b7
Rollup merge of #165230 - lsunsi:issue158773, r=adwinwhite
JonathanBrouwer Nov 3, 2026
e17fa98
Rollup merge of #165354 - beetrees:remove-abi-align, r=workingjubilee
JonathanBrouwer Nov 3, 2026
f10c1a8
Rollup merge of #165374 - jdonszelmann:move-trait-splitouts, r=ShoyuV…
JonathanBrouwer Nov 3, 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
55 changes: 26 additions & 29 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use rustc_index::bit_set::BitMatrix;
use tracing::{debug, trace};

use crate::{
AbiAlign, Align, BackendLaneCount, BackendRepr, FieldsShape, HasDataLayout, IndexSlice,
IndexVec, Integer, LayoutData, Niche, NicheOptimizations, NumScalableVectors, Primitive,
ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout, VariantLayout, Variants,
Align, BackendLaneCount, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec,
Integer, LayoutData, Niche, NicheOptimizations, NumScalableVectors, Primitive, ReprOptions,
Scalar, Size, StructKind, TagEncoding, TargetDataLayout, VariantLayout, Variants,
WrappingRange,
};

Expand Down Expand Up @@ -197,7 +197,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
align: element.align,
size,
max_repr_align: None,
unadjusted_abi_align: element.align.abi,
unadjusted_abi_align: element.align,
repr_c: element.repr_c,
randomization_seed: element.randomization_seed.wrapping_add(Hash64::new(count)),
})
Expand Down Expand Up @@ -426,7 +426,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
return Err(LayoutCalculatorError::UnexpectedUnsized(*field));
}

align = align.max(field.align.abi);
align = align.max(field.align);
max_repr_align = max_repr_align.max(field.max_repr_align);
size = cmp::max(size, field.size);

Expand All @@ -448,14 +448,14 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
// have the same alignment
if !matches!(common_abi, BackendRepr::Memory { .. }) {
assert_eq!(
common_align, field.align.abi,
common_align, field.align,
"non-Aggregate field with matching ABI but differing alignment"
);
}
}
} else {
// First non-ZST field: record its ABI and alignment
common_non_zst_repr_and_align = Ok(Some((field_abi, field.align.abi)));
common_non_zst_repr_and_align = Ok(Some((field_abi, field.align)));
}
}
}
Expand Down Expand Up @@ -517,7 +517,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
backend_repr,
largest_niche: None,
uninhabited: false,
align: AbiAlign::new(align),
align,
size: size.align_to(align),
max_repr_align,
unadjusted_abi_align,
Expand Down Expand Up @@ -622,9 +622,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
.map(|v| {
let st = self.layout_of_univariant(v, repr, StructKind::AlwaysSized).ok()?;

variants_info.push(VariantLayoutInfo { align_abi: st.align.abi });
variants_info.push(VariantLayoutInfo { align_abi: st.align });

align = align.max(st.align.abi);
align = align.max(st.align);
max_repr_align = max_repr_align.max(st.max_repr_align);
unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align);
combined_seed = combined_seed.wrapping_add(st.randomization_seed);
Expand Down Expand Up @@ -750,7 +750,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
largest_niche,
uninhabited,
size,
align: AbiAlign::new(align),
align,
max_repr_align,
unadjusted_abi_align,
repr_c: repr.c(),
Expand Down Expand Up @@ -814,7 +814,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
if repr.c() {
for fields in variants {
for field in fields {
prefix_align = prefix_align.max(field.align.abi);
prefix_align = prefix_align.max(field.align);
}
}
}
Expand All @@ -833,12 +833,12 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
for field_idx in st.fields.index_by_increasing_offset() {
let field = &field_layouts[FieldIdx::new(field_idx)];
if !field.is_1zst() {
start_align = start_align.min(field.align.abi);
start_align = start_align.min(field.align);
break;
}
}
size = cmp::max(size, st.size);
align = align.max(st.align.abi);
align = align.max(st.align);
max_repr_align = max_repr_align.max(st.max_repr_align);
unadjusted_abi_align = unadjusted_abi_align.max(st.unadjusted_abi_align);
combined_seed = combined_seed.wrapping_add(st.randomization_seed);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
};
if pair_offsets[FieldIdx::new(0)] == Size::ZERO
&& pair_offsets[FieldIdx::new(1)] == *offset
&& align == pair.align.abi
&& align == pair.align
&& size == pair.size
{
// We can use `ScalarPair` only when it matches our
Expand Down Expand Up @@ -1058,7 +1058,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
largest_niche,
uninhabited,
backend_repr: abi,
align: AbiAlign::new(align),
align,
size,
max_repr_align,
unadjusted_abi_align,
Expand Down Expand Up @@ -1157,7 +1157,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
// `alignment_group_key`, one or the other branch will be taken, so this is okay.
if let Some(pack) = pack {
// Return the packed alignment in bytes.
layout.align.abi.min(pack).bytes()
layout.align.min(pack).bytes()
} else {
// Returns `log2(effective-align)`. The calculation assumes that size is an
// integer multiple of align, except for ZSTs.
Expand Down Expand Up @@ -1276,13 +1276,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
}

// Invariant: offset < dl.obj_size_bound() <= 1<<61
let field_align = if let Some(pack) = pack {
field.align.min(AbiAlign::new(pack))
} else {
field.align
};
offset = offset.align_to(field_align.abi);
align = align.max(field_align.abi);
let field_align =
if let Some(pack) = pack { field.align.min(pack) } else { field.align };
offset = offset.align_to(field_align);
align = align.max(field_align);
max_repr_align = max_repr_align.max(field.max_repr_align);

debug!("univariant offset: {:?} field: {:#?}", offset, field);
Expand Down Expand Up @@ -1341,7 +1338,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
layout_of_single_non_zst_field = Some(field);

// Field fills the struct and it has a scalar or scalar pair ABI.
if offsets[i].bytes() == 0 && align == field.align.abi && size == field.size {
if offsets[i].bytes() == 0 && align == field.align && size == field.size {
match field.backend_repr {
// For plain scalars, or vectors of them, we can't unpack
// newtypes for `#[repr(C)]`, as that affects C ABIs.
Expand Down Expand Up @@ -1388,7 +1385,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
};
if offsets[i] == pair_offsets[FieldIdx::new(0)]
&& offsets[j] == pair_offsets[FieldIdx::new(1)]
&& align == pair.align.abi
&& align == pair.align
&& size == pair.size
{
// We can use `ScalarPair` only when it matches our
Expand Down Expand Up @@ -1428,7 +1425,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
backend_repr: abi,
largest_niche,
uninhabited,
align: AbiAlign::new(align),
align,
size,
max_repr_align,
unadjusted_abi_align,
Expand Down Expand Up @@ -1528,9 +1525,9 @@ where
largest_niche: elt.largest_niche,
uninhabited: false,
size,
align: AbiAlign::new(align),
align,
max_repr_align: None,
unadjusted_abi_align: elt.align.abi,
unadjusted_abi_align: elt.align,
repr_c: false,
randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count.as_u64())),
})
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_abi/src/layout/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ where
let mut variant = calc.layout_of_univariant(
&variant_only_tys.collect::<IndexVec<_, _>>(),
&ReprOptions::default(),
StructKind::Prefixed(prefix_size, prefix_align.abi),
StructKind::Prefixed(prefix_size, prefix_align),
)?;

let FieldsShape::Arbitrary { offsets, in_memory_order } = variant.fields else {
Expand Down Expand Up @@ -287,7 +287,7 @@ where
})
.collect::<Result<IndexVec<VariantIdx, _>, _>>()?;

size = size.align_to(align.abi);
size = size.align_to(align);

let uninhabited = prefix.uninhabited || variants.iter().all(|v| v.is_uninhabited());
let abi = BackendRepr::Memory { sized: true };
Expand All @@ -312,7 +312,7 @@ where
size,
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
unadjusted_abi_align: align,
repr_c: false,
randomization_seed: Default::default(),
})
Expand Down
13 changes: 6 additions & 7 deletions compiler/rustc_abi/src/layout/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use rustc_hashes::Hash64;
use rustc_index::{Idx, IndexVec};

use crate::{
AbiAlign, BackendRepr, FieldsShape, HasDataLayout, LayoutData, Niche, Primitive, Scalar, Size,
Variants,
BackendRepr, FieldsShape, HasDataLayout, LayoutData, Niche, Primitive, Scalar, Size, Variants,
};

/// "Simple" layout constructors that cannot fail.
Expand All @@ -21,7 +20,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
backend_repr: BackendRepr::Memory { sized },
largest_niche: None,
uninhabited: false,
align: AbiAlign::new(dl.i8_align),
align: dl.i8_align,
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
Expand All @@ -39,7 +38,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
backend_repr: BackendRepr::Memory { sized: true },
largest_niche: None,
uninhabited: true,
align: AbiAlign::new(dl.i8_align),
align: dl.i8_align,
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
Expand Down Expand Up @@ -83,7 +82,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
largest_niche,
uninhabited: false,
size,
align: AbiAlign::new(align),
align,
max_repr_align: None,
unadjusted_abi_align: align,
repr_c: false,
Expand Down Expand Up @@ -116,7 +115,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
backend_repr: BackendRepr::ScalarPair { a, b, b_offset },
largest_niche,
uninhabited: false,
align: AbiAlign::new(align),
align,
size,
max_repr_align: None,
unadjusted_abi_align: align,
Expand All @@ -143,7 +142,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
backend_repr: BackendRepr::Memory { sized: true },
largest_niche: None,
uninhabited: true,
align: AbiAlign::new(dl.i8_align),
align: dl.i8_align,
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'a> Layout<'a> {
}

pub fn align(self) -> Align {
self.0.0.align.abi
self.0.0.align
}

pub fn size(self) -> Size {
Expand Down
50 changes: 2 additions & 48 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::fmt;
#[cfg(feature = "nightly")]
use std::iter::Step;
use std::num::{NonZero, ParseIntError};
use std::ops::{Add, AddAssign, Deref, Mul, Sub};
use std::ops::{Add, AddAssign, Mul, Sub};
use std::range::RangeInclusive;
use std::str::FromStr;

Expand Down Expand Up @@ -1216,52 +1216,6 @@ impl Align {
}
}

/// A pair of alignments, ABI-mandated and preferred.
///
/// The "preferred" alignment is an LLVM concept that is virtually meaningless to Rust code:
/// it is not exposed semantically to programmers nor can they meaningfully affect it.
/// The only concern for us is that preferred alignment must not be less than the mandated alignment
/// and thus in practice the two values are almost always identical.
///
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
/// It is of effectively no consequence for layout in structs and on the stack.
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "nightly", derive(StableHash))]
pub struct AbiAlign {
pub abi: Align,
}

impl fmt::Debug for AbiAlign {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.abi, f)
}
}

impl AbiAlign {
#[inline]
pub fn new(align: Align) -> AbiAlign {
AbiAlign { abi: align }
}

#[inline]
pub fn min(self, other: AbiAlign) -> AbiAlign {
AbiAlign { abi: self.abi.min(other.abi) }
}

#[inline]
pub fn max(self, other: AbiAlign) -> AbiAlign {
AbiAlign { abi: self.abi.max(other.abi) }
}
}

impl Deref for AbiAlign {
type Target = Align;

fn deref(&self) -> &Self::Target {
&self.abi
}
}

/// Integers, also used for enum discriminants.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))]
Expand Down Expand Up @@ -2267,7 +2221,7 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// especially in the case of by-pointer struct returns, which allocate stack even when unused.
pub uninhabited: bool,

pub align: AbiAlign,
pub align: Align,
pub size: Size,

/// The largest alignment explicitly requested with `repr(align)` on this type or any field.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ pub enum ExprKind {
Lit(token::Lit),
/// A cast (e.g., `foo as f64`).
Cast(Box<Expr>, Box<Ty>),
/// A type ascription (e.g., `builtin # type_ascribe(42, usize)`).
/// A type ascription (e.g., `k#type_ascribe(42, usize)`).
///
/// Usually not written directly in user code but
/// indirectly via the macro `type_ascribe!(...)`.
Expand Down Expand Up @@ -1871,7 +1871,7 @@ pub enum ExprKind {
/// Output of the `asm!()` macro.
InlineAsm(Box<InlineAsm>),

/// An `offset_of` expression (e.g., `builtin # offset_of(Struct, field)`).
/// An `offset_of` expression (e.g., `k#offset_of(Struct, field)`).
///
/// Usually not written directly in user code but
/// indirectly via the macro `core::mem::offset_of!(...)`.
Expand Down Expand Up @@ -2570,7 +2570,7 @@ pub enum TyKind {
/// Pattern types like `pattern_type!(u32 is 1..=)`, which is the same as `NonZero<u32>`,
/// just as part of the type system.
Pat(Box<Ty>, Box<TyPat>),
/// A `field_of` expression (e.g., `builtin # field_of(Struct, field)`).
/// A `field_of` expression (e.g., `k#field_of(Struct, field)`).
///
/// Usually not written directly in user code but indirectly via the macro
/// `core::field::field_of!(...)`.
Expand Down
Loading