Enums in offset_of: update based on est31, scottmcm & llogiq review
This commit is contained in:
parent
e936416a8d
commit
d995bd61e7
15 changed files with 150 additions and 140 deletions
|
@ -17,7 +17,7 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::{self as hir};
|
||||
use rustc_hir::{self, CoroutineKind};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_target::abi::{FieldIdx, OffsetOfIdx, VariantIdx};
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
|
@ -1354,7 +1354,7 @@ pub enum NullOp<'tcx> {
|
|||
/// Returns the minimum alignment of a type
|
||||
AlignOf,
|
||||
/// Returns the offset of a field
|
||||
OffsetOf(&'tcx List<OffsetOfIdx>),
|
||||
OffsetOf(&'tcx List<(VariantIdx, FieldIdx)>),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
|
@ -26,7 +26,7 @@ use rustc_middle::ty::{
|
|||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::{sym, ErrorGuaranteed, Span, Symbol, DUMMY_SP};
|
||||
use rustc_span::{sym, Span, Symbol, DUMMY_SP};
|
||||
use rustc_target::abi::{FieldIdx, OffsetOfIdx, VariantIdx};
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||
use rustc_target::asm::InlineAsmRegOrRegClass;
|
||||
use std::fmt;
|
||||
use std::ops::Index;
|
||||
|
@ -491,7 +491,7 @@ pub enum ExprKind<'tcx> {
|
|||
/// Field offset (`offset_of!`)
|
||||
OffsetOf {
|
||||
container: Ty<'tcx>,
|
||||
fields: &'tcx List<OffsetOfIdx>,
|
||||
fields: &'tcx List<(VariantIdx, FieldIdx)>,
|
||||
},
|
||||
/// An expression taking a reference to a thread local.
|
||||
ThreadLocalRef(DefId),
|
||||
|
|
|
@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_serialize::{Decodable, Encodable};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{FieldIdx, OffsetOfIdx};
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||
pub use rustc_type_ir::{TyDecoder, TyEncoder};
|
||||
use std::hash::Hash;
|
||||
use std::intrinsics;
|
||||
|
@ -414,12 +414,14 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<Fi
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<OffsetOfIdx> {
|
||||
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D>
|
||||
for ty::List<(VariantIdx, FieldIdx)>
|
||||
{
|
||||
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||
let len = decoder.read_usize();
|
||||
decoder
|
||||
.interner()
|
||||
.mk_offset_of_from_iter((0..len).map::<OffsetOfIdx, _>(|_| Decodable::decode(decoder)))
|
||||
decoder.interner().mk_offset_of_from_iter(
|
||||
(0..len).map::<(VariantIdx, FieldIdx), _>(|_| Decodable::decode(decoder)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,7 +437,7 @@ impl_decodable_via_ref! {
|
|||
&'tcx ty::List<ty::BoundVariableKind>,
|
||||
&'tcx ty::List<ty::Clause<'tcx>>,
|
||||
&'tcx ty::List<FieldIdx>,
|
||||
&'tcx ty::List<OffsetOfIdx>,
|
||||
&'tcx ty::List<(VariantIdx, FieldIdx)>,
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
|
@ -63,7 +63,7 @@ use rustc_session::{Limit, MetadataKind, Session};
|
|||
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{FieldIdx, Layout, LayoutS, OffsetOfIdx, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
use rustc_type_ir::TyKind::*;
|
||||
use rustc_type_ir::WithCachedTypeInfo;
|
||||
|
@ -163,7 +163,7 @@ pub struct CtxtInterners<'tcx> {
|
|||
predefined_opaques_in_body: InternedSet<'tcx, PredefinedOpaquesData<'tcx>>,
|
||||
fields: InternedSet<'tcx, List<FieldIdx>>,
|
||||
local_def_ids: InternedSet<'tcx, List<LocalDefId>>,
|
||||
offset_of: InternedSet<'tcx, List<OffsetOfIdx>>,
|
||||
offset_of: InternedSet<'tcx, List<(VariantIdx, FieldIdx)>>,
|
||||
}
|
||||
|
||||
impl<'tcx> CtxtInterners<'tcx> {
|
||||
|
@ -1589,7 +1589,7 @@ slice_interners!(
|
|||
bound_variable_kinds: pub mk_bound_variable_kinds(ty::BoundVariableKind),
|
||||
fields: pub mk_fields(FieldIdx),
|
||||
local_def_ids: intern_local_def_ids(LocalDefId),
|
||||
offset_of: pub mk_offset_of(OffsetOfIdx),
|
||||
offset_of: pub mk_offset_of((VariantIdx, FieldIdx)),
|
||||
);
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
|
@ -1920,7 +1920,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
pub fn mk_offset_of_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: CollectAndApply<OffsetOfIdx, &'tcx List<OffsetOfIdx>>,
|
||||
T: CollectAndApply<(VariantIdx, FieldIdx), &'tcx List<(VariantIdx, FieldIdx)>>,
|
||||
{
|
||||
T::collect_and_apply(iter, |xs| self.mk_offset_of(xs))
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use rustc_macros::HashStable;
|
|||
use rustc_middle::mir::FakeReadCause;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{FieldIdx, OffsetOfIdx};
|
||||
use rustc_target::abi::{FieldIdx, VariantIdx};
|
||||
use std::{collections::hash_map::Entry, hash::Hash, iter};
|
||||
|
||||
use super::RvalueScopes;
|
||||
|
@ -205,7 +205,7 @@ pub struct TypeckResults<'tcx> {
|
|||
pub closure_size_eval: LocalDefIdMap<ClosureSizeProfileData<'tcx>>,
|
||||
|
||||
/// Container types and field indices of `offset_of!` expressions
|
||||
offset_of_data: ItemLocalMap<(Ty<'tcx>, Vec<OffsetOfIdx>)>,
|
||||
offset_of_data: ItemLocalMap<(Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeckResults<'tcx> {
|
||||
|
@ -464,13 +464,15 @@ impl<'tcx> TypeckResults<'tcx> {
|
|||
&self.coercion_casts
|
||||
}
|
||||
|
||||
pub fn offset_of_data(&self) -> LocalTableInContext<'_, (Ty<'tcx>, Vec<OffsetOfIdx>)> {
|
||||
pub fn offset_of_data(
|
||||
&self,
|
||||
) -> LocalTableInContext<'_, (Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)> {
|
||||
LocalTableInContext { hir_owner: self.hir_owner, data: &self.offset_of_data }
|
||||
}
|
||||
|
||||
pub fn offset_of_data_mut(
|
||||
&mut self,
|
||||
) -> LocalTableInContextMut<'_, (Ty<'tcx>, Vec<OffsetOfIdx>)> {
|
||||
) -> LocalTableInContextMut<'_, (Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.offset_of_data }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue