RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy,
};
use rustc_ast as ast;
-use rustc_attr as attr;
+use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::intern::Interned;
use rustc_data_structures::memmap::Mmap;
use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx};
use rustc_target::spec::abi;
+use rustc_type_ir::TypeFlags;
use smallvec::SmallVec;
use std::any::Any;
use std::borrow::Borrow;
bound_variable_kinds: InternedSet<'tcx, List<ty::BoundVariableKind>>,
layout: InternedSet<'tcx, Layout>,
adt_def: InternedSet<'tcx, AdtDef>,
-
- /// `#[stable]` and `#[unstable]` attributes
- stability: InternedSet<'tcx, attr::Stability>,
-
- /// `#[rustc_const_stable]` and `#[rustc_const_unstable]` attributes
- const_stability: InternedSet<'tcx, attr::ConstStability>,
}
impl<'tcx> CtxtInterners<'tcx> {
bound_variable_kinds: Default::default(),
layout: Default::default(),
adt_def: Default::default(),
- stability: Default::default(),
- const_stability: Default::default(),
}
}
/// Interns a type.
#[allow(rustc::usage_of_ty_tykind)]
#[inline(never)]
- fn intern_ty(&self, kind: TyKind<'tcx>) -> Ty<'tcx> {
+ fn intern_ty(
+ &self,
+ kind: TyKind<'tcx>,
+ sess: &Session,
+ resolutions: &ty::ResolverOutputs,
+ ) -> Ty<'tcx> {
Ty(Interned::new_unchecked(
self.type_
.intern(kind, |kind| {
let flags = super::flags::FlagComputation::for_kind(&kind);
+ let stable_hash = if flags.flags.intersects(TypeFlags::HAS_RE_INFER) {
+ Fingerprint::ZERO
+ } else {
+ let mut hasher = StableHasher::new();
+ let mut hcx = StableHashingContext::ignore_spans(
+ sess,
+ &resolutions.definitions,
+ &*resolutions.cstore,
+ );
+ kind.hash_stable(&mut hcx, &mut hasher);
+ hasher.finish()
+ };
+
let ty_struct = TyS {
kind,
flags: flags.flags,
outer_exclusive_binder: flags.outer_exclusive_binder,
+ stable_hash,
};
InternedInSet(self.arena.alloc(ty_struct))
}
impl<'tcx> CommonTypes<'tcx> {
- fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
- let mk = |ty| interners.intern_ty(ty);
+ fn new(
+ interners: &CtxtInterners<'tcx>,
+ sess: &Session,
+ resolutions: &ty::ResolverOutputs,
+ ) -> CommonTypes<'tcx> {
+ let mk = |ty| interners.intern_ty(ty, sess, resolutions);
CommonTypes {
unit: mk(Tuple(List::empty())),
s.fatal(&err);
});
let interners = CtxtInterners::new(arena);
- let common_types = CommonTypes::new(&interners);
+ let common_types = CommonTypes::new(&interners, s, &resolutions);
let common_lifetimes = CommonLifetimes::new(&interners);
let common_consts = CommonConsts::new(&interners, &common_types);
self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did)
}
- pub fn stability(self) -> &'tcx stability::Index<'tcx> {
+ pub fn stability(self) -> &'tcx stability::Index {
self.stability_index(())
}
writeln!(fmt, "InternalSubsts interner: #{}", self.0.interners.substs.len())?;
writeln!(fmt, "Region interner: #{}", self.0.interners.region.len())?;
- writeln!(fmt, "Stability interner: #{}", self.0.interners.stability.len())?;
- writeln!(
- fmt,
- "Const Stability interner: #{}",
- self.0.interners.const_stability.len()
- )?;
writeln!(
fmt,
"Const Allocation interner: #{}",
const_allocation: intern_const_alloc(Allocation),
layout: intern_layout(Layout),
adt_def: intern_adt_def(AdtDef),
- stability: intern_stability(attr::Stability),
- const_stability: intern_const_stability(attr::ConstStability),
}
macro_rules! slice_interners {
#[allow(rustc::usage_of_ty_tykind)]
#[inline]
pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> {
- self.interners.intern_ty(st)
+ self.interners.intern_ty(st, self.sess, &self.gcx.untracked_resolutions)
}
#[inline]