Skip to content

Commit 6d141c1

Browse files
committed
Implement Deref<LayoutS> for Layout
1 parent 67e5eb6 commit 6d141c1

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

compiler/rustc_middle/src/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
macro_rules! arena_types {
99
($macro:path) => (
1010
$macro!([
11-
[] layout: rustc_target::abi::LayoutS,
11+
[] layout: rustc_target::abi::LayoutS<rustc_target::abi::FieldIdx, rustc_target::abi::VariantIdx>,
1212
[] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
1313
// AdtDef are interned and compared by address
1414
[decode] adt_def: rustc_middle::ty::AdtDefData,

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub struct CtxtInterners<'tcx> {
152152
const_: InternedSet<'tcx, ConstData<'tcx>>,
153153
const_allocation: InternedSet<'tcx, Allocation>,
154154
bound_variable_kinds: InternedSet<'tcx, List<ty::BoundVariableKind>>,
155-
layout: InternedSet<'tcx, LayoutS>,
155+
layout: InternedSet<'tcx, LayoutS<FieldIdx, VariantIdx>>,
156156
adt_def: InternedSet<'tcx, AdtDefData>,
157157
external_constraints: InternedSet<'tcx, ExternalConstraintsData<'tcx>>,
158158
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<'tcx>>,
@@ -1521,7 +1521,7 @@ direct_interners! {
15211521
region: pub(crate) intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
15221522
const_: intern_const(ConstData<'tcx>): Const -> Const<'tcx>,
15231523
const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
1524-
layout: pub mk_layout(LayoutS): Layout -> Layout<'tcx>,
1524+
layout: pub mk_layout(LayoutS<FieldIdx, VariantIdx>): Layout -> Layout<'tcx>,
15251525
adt_def: pub mk_adt_def_from_data(AdtDefData): AdtDef -> AdtDef<'tcx>,
15261526
external_constraints: pub mk_external_constraints(ExternalConstraintsData<'tcx>):
15271527
ExternalConstraints -> ExternalConstraints<'tcx>,

compiler/rustc_target/src/abi/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ impl<'a> fmt::Debug for Layout<'a> {
7373
}
7474
}
7575

76+
impl<'a> Deref for Layout<'a> {
77+
type Target = &'a LayoutS<FieldIdx, VariantIdx>;
78+
fn deref(&self) -> &&'a LayoutS<FieldIdx, VariantIdx> {
79+
&self.0.0
80+
}
81+
}
82+
7683
impl<'a> Layout<'a> {
7784
pub fn fields(self) -> &'a FieldsShape<FieldIdx> {
7885
&self.0.0.fields

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn univariant_uninterned<'tcx>(
8585
fields: &IndexSlice<FieldIdx, Layout<'_>>,
8686
repr: &ReprOptions,
8787
kind: StructKind,
88-
) -> Result<LayoutS, &'tcx LayoutError<'tcx>> {
88+
) -> Result<LayoutS<FieldIdx, VariantIdx>, &'tcx LayoutError<'tcx>> {
8989
let dl = cx.data_layout();
9090
let pack = repr.pack;
9191
if pack.is_some() && repr.align.is_some() {

0 commit comments

Comments
 (0)