mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Implement Deref<LayoutS> for Layout
This commit is contained in:
parent
67e5eb6cec
commit
6d141c11c0
@ -8,7 +8,7 @@
|
||||
macro_rules! arena_types {
|
||||
($macro:path) => (
|
||||
$macro!([
|
||||
[] layout: rustc_target::abi::LayoutS,
|
||||
[] layout: rustc_target::abi::LayoutS<rustc_target::abi::FieldIdx, rustc_target::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,
|
||||
|
@ -152,7 +152,7 @@ pub struct CtxtInterners<'tcx> {
|
||||
const_: InternedSet<'tcx, ConstData<'tcx>>,
|
||||
const_allocation: InternedSet<'tcx, Allocation>,
|
||||
bound_variable_kinds: InternedSet<'tcx, List<ty::BoundVariableKind>>,
|
||||
layout: InternedSet<'tcx, LayoutS>,
|
||||
layout: InternedSet<'tcx, LayoutS<FieldIdx, VariantIdx>>,
|
||||
adt_def: InternedSet<'tcx, AdtDefData>,
|
||||
external_constraints: InternedSet<'tcx, ExternalConstraintsData<'tcx>>,
|
||||
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<'tcx>>,
|
||||
@ -1521,7 +1521,7 @@ direct_interners! {
|
||||
region: pub(crate) intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
|
||||
const_: intern_const(ConstData<'tcx>): Const -> Const<'tcx>,
|
||||
const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
|
||||
layout: pub mk_layout(LayoutS): Layout -> Layout<'tcx>,
|
||||
layout: pub mk_layout(LayoutS<FieldIdx, VariantIdx>): Layout -> Layout<'tcx>,
|
||||
adt_def: pub mk_adt_def_from_data(AdtDefData): AdtDef -> AdtDef<'tcx>,
|
||||
external_constraints: pub mk_external_constraints(ExternalConstraintsData<'tcx>):
|
||||
ExternalConstraints -> ExternalConstraints<'tcx>,
|
||||
|
@ -73,6 +73,13 @@ impl<'a> fmt::Debug for Layout<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for Layout<'a> {
|
||||
type Target = &'a LayoutS<FieldIdx, VariantIdx>;
|
||||
fn deref(&self) -> &&'a LayoutS<FieldIdx, VariantIdx> {
|
||||
&self.0.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Layout<'a> {
|
||||
pub fn fields(self) -> &'a FieldsShape<FieldIdx> {
|
||||
&self.0.0.fields
|
||||
|
@ -85,7 +85,7 @@ fn univariant_uninterned<'tcx>(
|
||||
fields: &IndexSlice<FieldIdx, Layout<'_>>,
|
||||
repr: &ReprOptions,
|
||||
kind: StructKind,
|
||||
) -> Result<LayoutS, &'tcx LayoutError<'tcx>> {
|
||||
) -> Result<LayoutS<FieldIdx, VariantIdx>, &'tcx LayoutError<'tcx>> {
|
||||
let dl = cx.data_layout();
|
||||
let pack = repr.pack;
|
||||
if pack.is_some() && repr.align.is_some() {
|
||||
|
Loading…
Reference in New Issue
Block a user