compiler: Rename LayoutS to LayoutData

The last {UninternedType}S is in captivity. The galaxy is at peace.
This commit is contained in:
Jubilee Young 2024-10-27 22:31:09 -07:00
parent df4ca44d3f
commit e1781297f3
8 changed files with 57 additions and 57 deletions

View File

@ -7,7 +7,7 @@
use crate::{
Abi, AbiAndPrefAlign, Align, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer,
LayoutS, Niche, NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding,
LayoutData, Niche, NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding,
Variants, WrappingRange,
};
@ -26,7 +26,7 @@ fn absent<'a, FieldIdx, VariantIdx, F>(fields: &IndexSlice<FieldIdx, F>) -> bool
where
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug,
{
let uninhabited = fields.iter().any(|f| f.abi.is_uninhabited());
// We cannot ignore alignment; that might lead us to entirely discard a variant and
@ -89,7 +89,7 @@ pub fn fallback_fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
type LayoutCalculatorResult<FieldIdx, VariantIdx, F> =
Result<LayoutS<FieldIdx, VariantIdx>, LayoutCalculatorError<F>>;
Result<LayoutData<FieldIdx, VariantIdx>, LayoutCalculatorError<F>>;
#[derive(Clone, Copy, Debug)]
pub struct LayoutCalculator<Cx> {
@ -105,7 +105,7 @@ pub fn scalar_pair<FieldIdx: Idx, VariantIdx: Idx>(
&self,
a: Scalar,
b: Scalar,
) -> LayoutS<FieldIdx, VariantIdx> {
) -> LayoutData<FieldIdx, VariantIdx> {
let dl = self.cx.data_layout();
let b_align = b.align(dl);
let align = a.align(dl).max(b_align).max(dl.aggregate_align);
@ -119,7 +119,7 @@ pub fn scalar_pair<FieldIdx: Idx, VariantIdx: Idx>(
.chain(Niche::from_scalar(dl, Size::ZERO, a))
.max_by_key(|niche| niche.available(dl));
LayoutS {
LayoutData {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Arbitrary {
offsets: [Size::ZERO, b_offset].into(),
@ -138,7 +138,7 @@ pub fn univariant<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
fields: &IndexSlice<FieldIdx, F>,
@ -211,9 +211,9 @@ pub fn univariant<
pub fn layout_of_never_type<FieldIdx: Idx, VariantIdx: Idx>(
&self,
) -> LayoutS<FieldIdx, VariantIdx> {
) -> LayoutData<FieldIdx, VariantIdx> {
let dl = self.cx.data_layout();
LayoutS {
LayoutData {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Primitive,
abi: Abi::Uninhabited,
@ -229,7 +229,7 @@ pub fn layout_of_struct_or_enum<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
repr: &ReprOptions,
@ -292,7 +292,7 @@ pub fn layout_of_union<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
repr: &ReprOptions,
@ -384,7 +384,7 @@ pub fn layout_of_union<
return Err(LayoutCalculatorError::EmptyUnion);
};
Ok(LayoutS {
Ok(LayoutData {
variants: Variants::Single { index: only_variant_idx },
fields: FieldsShape::Union(union_field_count),
abi,
@ -401,7 +401,7 @@ fn layout_of_struct<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
repr: &ReprOptions,
@ -501,7 +501,7 @@ fn layout_of_enum<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
repr: &ReprOptions,
@ -516,8 +516,8 @@ fn layout_of_enum<
// overall LayoutS. Store the overall LayoutS
// and the variant LayoutSs here until then.
struct TmpLayout<FieldIdx: Idx, VariantIdx: Idx> {
layout: LayoutS<FieldIdx, VariantIdx>,
variants: IndexVec<VariantIdx, LayoutS<FieldIdx, VariantIdx>>,
layout: LayoutData<FieldIdx, VariantIdx>,
variants: IndexVec<VariantIdx, LayoutData<FieldIdx, VariantIdx>>,
}
let dl = self.cx.data_layout();
@ -649,7 +649,7 @@ struct TmpLayout<FieldIdx: Idx, VariantIdx: Idx> {
Abi::Aggregate { sized: true }
};
let layout = LayoutS {
let layout = LayoutData {
variants: Variants::Multiple {
tag: niche_scalar,
tag_encoding: TagEncoding::Niche {
@ -958,7 +958,7 @@ struct TmpLayout<FieldIdx: Idx, VariantIdx: Idx> {
let largest_niche = Niche::from_scalar(dl, Size::ZERO, tag);
let tagged_layout = LayoutS {
let tagged_layout = LayoutData {
variants: Variants::Multiple {
tag,
tag_encoding: TagEncoding::Direct,
@ -1013,7 +1013,7 @@ fn univariant_biased<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug + Copy,
>(
&self,
fields: &IndexSlice<FieldIdx, F>,
@ -1341,7 +1341,7 @@ fn univariant_biased<
unadjusted_abi_align
};
Ok(LayoutS {
Ok(LayoutData {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Arbitrary { offsets, memory_index },
abi,
@ -1357,10 +1357,10 @@ fn format_field_niches<
'a,
FieldIdx: Idx,
VariantIdx: Idx,
F: Deref<Target = &'a LayoutS<FieldIdx, VariantIdx>> + fmt::Debug,
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug,
>(
&self,
layout: &LayoutS<FieldIdx, VariantIdx>,
layout: &LayoutData<FieldIdx, VariantIdx>,
fields: &IndexSlice<FieldIdx, F>,
) -> String {
let dl = self.cx.data_layout();

View File

@ -58,7 +58,7 @@ pub struct VariantIdx {
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
#[rustc_pass_by_value]
pub struct Layout<'a>(pub Interned<'a, LayoutS<FieldIdx, VariantIdx>>);
pub struct Layout<'a>(pub Interned<'a, LayoutData<FieldIdx, VariantIdx>>);
impl<'a> fmt::Debug for Layout<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@ -68,8 +68,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
impl<'a> Deref for Layout<'a> {
type Target = &'a LayoutS<FieldIdx, VariantIdx>;
fn deref(&self) -> &&'a LayoutS<FieldIdx, VariantIdx> {
type Target = &'a LayoutData<FieldIdx, VariantIdx>;
fn deref(&self) -> &&'a LayoutData<FieldIdx, VariantIdx> {
&self.0.0
}
}
@ -142,8 +142,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
impl<'a, Ty> Deref for TyAndLayout<'a, Ty> {
type Target = &'a LayoutS<FieldIdx, VariantIdx>;
fn deref(&self) -> &&'a LayoutS<FieldIdx, VariantIdx> {
type Target = &'a LayoutData<FieldIdx, VariantIdx>;
fn deref(&self) -> &&'a LayoutData<FieldIdx, VariantIdx> {
&self.layout.0.0
}
}

View File

@ -1485,7 +1485,7 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
tag: Scalar,
tag_encoding: TagEncoding<VariantIdx>,
tag_field: usize,
variants: IndexVec<VariantIdx, LayoutS<FieldIdx, VariantIdx>>,
variants: IndexVec<VariantIdx, LayoutData<FieldIdx, VariantIdx>>,
},
}
@ -1603,7 +1603,7 @@ pub fn reserve<C: HasDataLayout>(&self, cx: &C, count: u128) -> Option<(u128, Sc
// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
pub struct LayoutS<FieldIdx: Idx, VariantIdx: Idx> {
pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// Says where the fields are located within the layout.
pub fields: FieldsShape<FieldIdx>,
@ -1643,7 +1643,7 @@ pub struct LayoutS<FieldIdx: Idx, VariantIdx: Idx> {
pub unadjusted_abi_align: Align,
}
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
pub fn is_aggregate(&self) -> bool {
match self.abi {
@ -1656,7 +1656,7 @@ pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
let size = scalar.size(cx);
let align = scalar.align(cx);
LayoutS {
LayoutData {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Primitive,
abi: Abi::Scalar(scalar),
@ -1669,7 +1669,7 @@ pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
}
}
impl<FieldIdx: Idx, VariantIdx: Idx> fmt::Debug for LayoutS<FieldIdx, VariantIdx>
impl<FieldIdx: Idx, VariantIdx: Idx> fmt::Debug for LayoutData<FieldIdx, VariantIdx>
where
FieldsShape<FieldIdx>: fmt::Debug,
Variants<FieldIdx, VariantIdx>: fmt::Debug,
@ -1678,7 +1678,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// This is how `Layout` used to print before it become
// `Interned<LayoutS>`. We print it like this to avoid having to update
// expected output in a lot of tests.
let LayoutS {
let LayoutData {
size,
align,
abi,
@ -1723,7 +1723,7 @@ pub struct PointeeInfo {
pub safe: Option<PointerKind>,
}
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// Returns `true` if the layout corresponds to an unsized type.
#[inline]
pub fn is_unsized(&self) -> bool {

View File

@ -8,7 +8,7 @@
macro_rules! arena_types {
($macro:path) => (
$macro!([
[] layout: rustc_target::abi::LayoutS<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>,
[] layout: rustc_abi::LayoutData<rustc_abi::FieldIdx, rustc_abi::VariantIdx>,
[] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
// AdtDef are interned and compared by address
[decode] adt_def: rustc_middle::ty::AdtDefData,

View File

@ -12,7 +12,7 @@
use std::ops::{Bound, Deref};
use std::{fmt, iter, mem};
use rustc_abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx};
use rustc_abi::{FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx};
use rustc_ast::{self as ast, attr};
use rustc_data_structures::defer;
use rustc_data_structures::fingerprint::Fingerprint;
@ -766,7 +766,7 @@ pub struct CtxtInterners<'tcx> {
pat: InternedSet<'tcx, PatternKind<'tcx>>,
const_allocation: InternedSet<'tcx, Allocation>,
bound_variable_kinds: InternedSet<'tcx, List<ty::BoundVariableKind>>,
layout: InternedSet<'tcx, LayoutS<FieldIdx, VariantIdx>>,
layout: InternedSet<'tcx, LayoutData<FieldIdx, VariantIdx>>,
adt_def: InternedSet<'tcx, AdtDefData>,
external_constraints: InternedSet<'tcx, ExternalConstraintsData<TyCtxt<'tcx>>>,
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<TyCtxt<'tcx>>>,
@ -2469,7 +2469,7 @@ impl<'tcx> TyCtxt<'tcx> {
region: pub(crate) intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
pat: pub mk_pat(PatternKind<'tcx>): Pattern -> Pattern<'tcx>,
const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
layout: pub mk_layout(LayoutS<FieldIdx, VariantIdx>): Layout -> Layout<'tcx>,
layout: pub mk_layout(LayoutData<FieldIdx, VariantIdx>): Layout -> Layout<'tcx>,
adt_def: pub mk_adt_def_from_data(AdtDefData): AdtDef -> AdtDef<'tcx>,
external_constraints: pub mk_external_constraints(ExternalConstraintsData<TyCtxt<'tcx>>):
ExternalConstraints -> ExternalConstraints<'tcx>,

View File

@ -4,7 +4,7 @@
use rustc_abi::Primitive::{self, Float, Int, Pointer};
use rustc_abi::{
Abi, AddressSpace, Align, FieldsShape, HasDataLayout, Integer, LayoutCalculator, LayoutS,
Abi, AddressSpace, Align, FieldsShape, HasDataLayout, Integer, LayoutCalculator, LayoutData,
PointeeInfo, PointerKind, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, Variants,
};
use rustc_error_messages::DiagMessage;
@ -751,7 +751,7 @@ fn ty_and_layout_for_variant(
ty::Adt(def, _) => def.variant(variant_index).fields.len(),
_ => bug!("`ty_and_layout_for_variant` on unexpected type {}", this.ty),
};
tcx.mk_layout(LayoutS {
tcx.mk_layout(LayoutData {
variants: Variants::Single { index: variant_index },
fields: match NonZero::new(fields) {
Some(fields) => FieldsShape::Union(fields),
@ -788,7 +788,7 @@ fn field_ty_or_layout<'tcx>(
let tcx = cx.tcx();
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
TyAndLayout {
layout: tcx.mk_layout(LayoutS::scalar(cx, tag)),
layout: tcx.mk_layout(LayoutData::scalar(cx, tag)),
ty: tag.primitive().to_ty(tcx),
}
};

View File

@ -50,7 +50,7 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
}
impl<'tcx> Stable<'tcx>
for rustc_abi::LayoutS<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>
for rustc_abi::LayoutData<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>
{
type T = LayoutShape;

View File

@ -6,7 +6,7 @@
use rustc_abi::Primitive::{self, Float, Int, Pointer};
use rustc_abi::{
Abi, AbiAndPrefAlign, AddressSpace, Align, FieldsShape, HasDataLayout, LayoutCalculatorError,
LayoutS, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding, Variants, WrappingRange,
LayoutData, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding, Variants, WrappingRange,
};
use rustc_index::bit_set::BitSet;
use rustc_index::{IndexSlice, IndexVec};
@ -131,7 +131,7 @@ fn univariant_uninterned<'tcx>(
fields: &IndexSlice<FieldIdx, TyAndLayout<'tcx>>,
repr: &ReprOptions,
kind: StructKind,
) -> Result<LayoutS<FieldIdx, VariantIdx>, &'tcx LayoutError<'tcx>> {
) -> Result<LayoutData<FieldIdx, VariantIdx>, &'tcx LayoutError<'tcx>> {
let pack = repr.pack;
if pack.is_some() && repr.align.is_some() {
cx.tcx().dcx().bug("struct cannot be packed and aligned");
@ -159,7 +159,7 @@ fn layout_of_uncached<'tcx>(
assert!(size.bits() <= 128);
Scalar::Initialized { value, valid_range: WrappingRange::full(size) }
};
let scalar = |value: Primitive| tcx.mk_layout(LayoutS::scalar(cx, scalar_unit(value)));
let scalar = |value: Primitive| tcx.mk_layout(LayoutData::scalar(cx, scalar_unit(value)));
let univariant =
|fields: &IndexSlice<FieldIdx, TyAndLayout<'tcx>>, repr: &ReprOptions, kind| {
@ -170,7 +170,7 @@ fn layout_of_uncached<'tcx>(
Ok(match *ty.kind() {
ty::Pat(ty, pat) => {
let layout = cx.layout_of(ty)?.layout;
let mut layout = LayoutS::clone(&layout.0);
let mut layout = LayoutData::clone(&layout.0);
match *pat {
ty::PatternKind::Range { start, end, include_end } => {
if let Abi::Scalar(scalar) | Abi::ScalarPair(scalar, _) = &mut layout.abi {
@ -206,11 +206,11 @@ fn layout_of_uncached<'tcx>(
}
// Basic scalars.
ty::Bool => tcx.mk_layout(LayoutS::scalar(cx, Scalar::Initialized {
ty::Bool => tcx.mk_layout(LayoutData::scalar(cx, Scalar::Initialized {
value: Int(I8, false),
valid_range: WrappingRange { start: 0, end: 1 },
})),
ty::Char => tcx.mk_layout(LayoutS::scalar(cx, Scalar::Initialized {
ty::Char => tcx.mk_layout(LayoutData::scalar(cx, Scalar::Initialized {
value: Int(I32, false),
valid_range: WrappingRange { start: 0, end: 0x10FFFF },
})),
@ -220,7 +220,7 @@ fn layout_of_uncached<'tcx>(
ty::FnPtr(..) => {
let mut ptr = scalar_unit(Pointer(dl.instruction_address_space));
ptr.valid_range_mut().start = 1;
tcx.mk_layout(LayoutS::scalar(cx, ptr))
tcx.mk_layout(LayoutData::scalar(cx, ptr))
}
// The never type.
@ -235,7 +235,7 @@ fn layout_of_uncached<'tcx>(
let pointee = tcx.normalize_erasing_regions(param_env, pointee);
if pointee.is_sized(tcx, param_env) {
return Ok(tcx.mk_layout(LayoutS::scalar(cx, data_ptr)));
return Ok(tcx.mk_layout(LayoutData::scalar(cx, data_ptr)));
}
let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type()
@ -272,7 +272,7 @@ fn layout_of_uncached<'tcx>(
let metadata_layout = cx.layout_of(metadata_ty)?;
// If the metadata is a 1-zst, then the pointer is thin.
if metadata_layout.is_1zst() {
return Ok(tcx.mk_layout(LayoutS::scalar(cx, data_ptr)));
return Ok(tcx.mk_layout(LayoutData::scalar(cx, data_ptr)));
}
let Abi::Scalar(metadata) = metadata_layout.abi else {
@ -285,7 +285,7 @@ fn layout_of_uncached<'tcx>(
match unsized_part.kind() {
ty::Foreign(..) => {
return Ok(tcx.mk_layout(LayoutS::scalar(cx, data_ptr)));
return Ok(tcx.mk_layout(LayoutData::scalar(cx, data_ptr)));
}
ty::Slice(_) | ty::Str => scalar_unit(Int(dl.ptr_sized_integer(), false)),
ty::Dynamic(..) => {
@ -337,7 +337,7 @@ fn layout_of_uncached<'tcx>(
let largest_niche = if count != 0 { element.largest_niche } else { None };
tcx.mk_layout(LayoutS {
tcx.mk_layout(LayoutData {
variants: Variants::Single { index: FIRST_VARIANT },
fields: FieldsShape::Array { stride: element.size, count },
abi,
@ -350,7 +350,7 @@ fn layout_of_uncached<'tcx>(
}
ty::Slice(element) => {
let element = cx.layout_of(element)?;
tcx.mk_layout(LayoutS {
tcx.mk_layout(LayoutData {
variants: Variants::Single { index: FIRST_VARIANT },
fields: FieldsShape::Array { stride: element.size, count: 0 },
abi: Abi::Aggregate { sized: false },
@ -361,7 +361,7 @@ fn layout_of_uncached<'tcx>(
unadjusted_abi_align: element.align.abi,
})
}
ty::Str => tcx.mk_layout(LayoutS {
ty::Str => tcx.mk_layout(LayoutData {
variants: Variants::Single { index: FIRST_VARIANT },
fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 },
abi: Abi::Aggregate { sized: false },
@ -532,7 +532,7 @@ fn layout_of_uncached<'tcx>(
FieldsShape::Array { stride: e_ly.size, count: e_len }
};
tcx.mk_layout(LayoutS {
tcx.mk_layout(LayoutData {
variants: Variants::Single { index: FIRST_VARIANT },
fields,
abi,
@ -835,7 +835,7 @@ fn coroutine_layout<'tcx>(
};
let tag_layout = TyAndLayout {
ty: discr_int.to_ty(tcx, /* signed = */ false),
layout: tcx.mk_layout(LayoutS::scalar(cx, tag)),
layout: tcx.mk_layout(LayoutData::scalar(cx, tag)),
};
let promoted_layouts = ineligible_locals.iter().map(|local| {
@ -991,7 +991,7 @@ fn coroutine_layout<'tcx>(
Abi::Aggregate { sized: true }
};
let layout = tcx.mk_layout(LayoutS {
let layout = tcx.mk_layout(LayoutData {
variants: Variants::Multiple {
tag,
tag_encoding: TagEncoding::Direct,