use hir::{map as hir_map, FreevarMap, TraitMap};
use hir::def::{Def, CtorKind, ExportMap};
use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
+use ich::StableHashingContext;
use middle::const_val::ConstVal;
use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
use middle::privacy::AccessLevels;
use rustc_const_math::ConstInt;
use rustc_data_structures::accumulate_vec::IntoIter as AccIntoIter;
+use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
+ HashStable};
use hir;
use hir::itemlikevisit::ItemLikeVisitor;
}
}
+impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::TyS<'tcx> {
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'a, 'tcx>,
+ hasher: &mut StableHasher<W>) {
+ let ty::TyS {
+ ref sty,
+
+ // The other fields just provide fast access to information that is
+ // also contained in `sty`, so no need to hash them.
+ flags: _,
+ region_depth: _,
+ } = *self;
+
+ sty.hash_stable(hcx, hasher);
+ }
+}
+
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
impl<'tcx> serialize::UseSpecializedEncodable for Ty<'tcx> {}
impl<'tcx> serialize::UseSpecializedDecodable for &'tcx AdtDef {}
+
+impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for AdtDef {
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'a, 'tcx>,
+ hasher: &mut StableHasher<W>) {
+ let ty::AdtDef {
+ did,
+ ref variants,
+ ref flags,
+ ref repr,
+ } = *self;
+
+ did.hash_stable(hcx, hasher);
+ variants.hash_stable(hcx, hasher);
+ flags.hash_stable(hcx, hasher);
+ repr.hash_stable(hcx, hasher);
+ }
+}
+
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum AdtKind { Struct, Union, Enum }
pub packed: bool,
pub simd: bool,
pub int: Option<attr::IntType>,
+ // Internal only for now. If true, don't reorder fields.
+ pub linear: bool,
}
+impl_stable_hash_for!(struct ReprOptions {
+ c,
+ packed,
+ simd,
+ int,
+ linear
+});
+
impl ReprOptions {
pub fn new(tcx: TyCtxt, did: DefId) -> ReprOptions {
let mut ret = ReprOptions::default();
ret.simd = true;
}
+ // This is here instead of layout because the choice must make it into metadata.
+ ret.linear = !tcx.consider_optimizing(|| format!("Reorder fields of {:?}",
+ tcx.item_path_str(did)));
ret
}
}
}
+ #[inline]
+ pub fn def_path_hash(self, def_id: DefId) -> u64 {
+ if def_id.is_local() {
+ self.hir.definitions().def_path_hash(def_id.index)
+ } else {
+ self.sess.cstore.def_path_hash(def_id)
+ }
+ }
+
pub fn def_span(self, def_id: DefId) -> Span {
if let Some(id) = self.hir.as_local_node_id(def_id) {
self.hir.span(id)