1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! This module contains `HashStable` implementations for various HIR data
12 //! types in no particular order.
15 use hir::map::DefPathHash;
16 use hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX};
17 use ich::{StableHashingContext, NodeIdHashingMode};
18 use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
19 StableHasher, StableHasherResult};
24 impl<'a> HashStable<StableHashingContext<'a>> for DefId {
26 fn hash_stable<W: StableHasherResult>(&self,
27 hcx: &mut StableHashingContext<'a>,
28 hasher: &mut StableHasher<W>) {
29 hcx.def_path_hash(*self).hash_stable(hcx, hasher);
33 impl<'a> ToStableHashKey<StableHashingContext<'a>> for DefId {
34 type KeyType = DefPathHash;
37 fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
38 hcx.def_path_hash(*self)
42 impl<'a> HashStable<StableHashingContext<'a>> for LocalDefId {
44 fn hash_stable<W: StableHasherResult>(&self,
45 hcx: &mut StableHashingContext<'a>,
46 hasher: &mut StableHasher<W>) {
47 hcx.def_path_hash(self.to_def_id()).hash_stable(hcx, hasher);
51 impl<'a> ToStableHashKey<StableHashingContext<'a>> for LocalDefId {
52 type KeyType = DefPathHash;
55 fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
56 hcx.def_path_hash(self.to_def_id())
60 impl<'a> HashStable<StableHashingContext<'a>> for CrateNum {
62 fn hash_stable<W: StableHasherResult>(&self,
63 hcx: &mut StableHashingContext<'a>,
64 hasher: &mut StableHasher<W>) {
65 hcx.def_path_hash(DefId {
67 index: CRATE_DEF_INDEX
68 }).hash_stable(hcx, hasher);
72 impl<'a> ToStableHashKey<StableHashingContext<'a>> for CrateNum {
73 type KeyType = DefPathHash;
76 fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
77 let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX };
78 def_id.to_stable_hash_key(hcx)
82 impl_stable_hash_for!(tuple_struct hir::ItemLocalId { index });
84 impl<'a> ToStableHashKey<StableHashingContext<'a>>
85 for hir::ItemLocalId {
86 type KeyType = hir::ItemLocalId;
89 fn to_stable_hash_key(&self,
90 _: &StableHashingContext<'a>)
96 // The following implementations of HashStable for ItemId, TraitItemId, and
97 // ImplItemId deserve special attention. Normally we do not hash NodeIds within
98 // the HIR, since they just signify a HIR nodes own path. But ItemId et al
99 // are used when another item in the HIR is *referenced* and we certainly
100 // want to pick up on a reference changing its target, so we hash the NodeIds
101 // in "DefPath Mode".
103 impl<'a> HashStable<StableHashingContext<'a>> for hir::ItemId {
104 fn hash_stable<W: StableHasherResult>(&self,
105 hcx: &mut StableHashingContext<'a>,
106 hasher: &mut StableHasher<W>) {
111 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
112 id.hash_stable(hcx, hasher);
117 impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItemId {
118 fn hash_stable<W: StableHasherResult>(&self,
119 hcx: &mut StableHashingContext<'a>,
120 hasher: &mut StableHasher<W>) {
121 let hir::TraitItemId {
125 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
126 node_id.hash_stable(hcx, hasher);
131 impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItemId {
132 fn hash_stable<W: StableHasherResult>(&self,
133 hcx: &mut StableHashingContext<'a>,
134 hasher: &mut StableHasher<W>) {
135 let hir::ImplItemId {
139 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
140 node_id.hash_stable(hcx, hasher);
145 impl_stable_hash_for!(enum hir::ParamName {
150 impl_stable_hash_for!(enum hir::LifetimeName {
157 impl_stable_hash_for!(struct hir::Label {
162 impl_stable_hash_for!(struct hir::Lifetime {
168 impl_stable_hash_for!(struct hir::Path {
174 impl_stable_hash_for!(struct hir::PathSegment {
180 impl_stable_hash_for!(enum hir::GenericArg {
185 impl_stable_hash_for!(struct hir::GenericArgs {
191 impl_stable_hash_for!(enum hir::GenericBound {
192 Trait(poly_trait_ref, trait_bound_modifier),
196 impl_stable_hash_for!(enum hir::TraitBoundModifier {
201 impl_stable_hash_for!(struct hir::GenericParam {
211 impl<'a> HashStable<StableHashingContext<'a>> for hir::GenericParamKind {
212 fn hash_stable<W: StableHasherResult>(&self,
213 hcx: &mut StableHashingContext<'a>,
214 hasher: &mut StableHasher<W>) {
215 mem::discriminant(self).hash_stable(hcx, hasher);
217 hir::GenericParamKind::Lifetime { in_band } => {
218 in_band.hash_stable(hcx, hasher);
220 hir::GenericParamKind::Type { ref default, synthetic } => {
221 default.hash_stable(hcx, hasher);
222 synthetic.hash_stable(hcx, hasher);
228 impl_stable_hash_for!(struct hir::Generics {
234 impl_stable_hash_for!(enum hir::SyntheticTyParamKind {
238 impl_stable_hash_for!(struct hir::WhereClause {
243 impl_stable_hash_for!(enum hir::WherePredicate {
244 BoundPredicate(pred),
245 RegionPredicate(pred),
249 impl_stable_hash_for!(struct hir::WhereBoundPredicate {
251 bound_generic_params,
256 impl_stable_hash_for!(struct hir::WhereRegionPredicate {
262 impl_stable_hash_for!(struct hir::WhereEqPredicate {
269 impl_stable_hash_for!(struct hir::MutTy {
274 impl_stable_hash_for!(struct hir::MethodSig {
281 impl_stable_hash_for!(struct hir::TypeBinding {
288 impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
289 fn hash_stable<W: StableHasherResult>(&self,
290 hcx: &mut StableHashingContext<'a>,
291 hasher: &mut StableHasher<W>) {
292 hcx.while_hashing_hir_bodies(true, |hcx| {
300 node.hash_stable(hcx, hasher);
301 span.hash_stable(hcx, hasher);
306 impl_stable_hash_for!(enum hir::PrimTy {
315 impl_stable_hash_for!(struct hir::BareFnTy {
323 impl_stable_hash_for!(struct hir::ExistTy {
329 impl_stable_hash_for!(enum hir::Ty_ {
338 TyTraitObject(trait_refs, lifetime),
339 TyImplTraitExistential(existty, def_id, lifetimes),
345 impl_stable_hash_for!(struct hir::FnDecl {
352 impl_stable_hash_for!(enum hir::FunctionRetTy {
357 impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitRef {
358 fn hash_stable<W: StableHasherResult>(&self,
359 hcx: &mut StableHashingContext<'a>,
360 hasher: &mut StableHasher<W>) {
363 // Don't hash the ref_id. It is tracked via the thing it is used to access
367 path.hash_stable(hcx, hasher);
372 impl_stable_hash_for!(struct hir::PolyTraitRef {
373 bound_generic_params,
378 impl_stable_hash_for!(enum hir::QPath {
380 TypeRelative(t, path_segment)
383 impl_stable_hash_for!(struct hir::MacroDef {
394 impl<'a> HashStable<StableHashingContext<'a>> for hir::Block {
395 fn hash_stable<W: StableHasherResult>(&self,
396 hcx: &mut StableHashingContext<'a>,
397 hasher: &mut StableHasher<W>) {
409 stmts.hash_stable(hcx, hasher);
410 expr.hash_stable(hcx, hasher);
411 rules.hash_stable(hcx, hasher);
412 span.hash_stable(hcx, hasher);
413 recovered.hash_stable(hcx, hasher);
414 targeted_by_break.hash_stable(hcx, hasher);
418 impl<'a> HashStable<StableHashingContext<'a>> for hir::Pat {
419 fn hash_stable<W: StableHasherResult>(&self,
420 hcx: &mut StableHashingContext<'a>,
421 hasher: &mut StableHasher<W>) {
430 node.hash_stable(hcx, hasher);
431 span.hash_stable(hcx, hasher);
435 impl_stable_hash_for_spanned!(hir::FieldPat);
437 impl<'a> HashStable<StableHashingContext<'a>> for hir::FieldPat {
438 fn hash_stable<W: StableHasherResult>(&self,
439 hcx: &mut StableHashingContext<'a>,
440 hasher: &mut StableHasher<W>) {
448 ident.hash_stable(hcx, hasher);
449 pat.hash_stable(hcx, hasher);
450 is_shorthand.hash_stable(hcx, hasher);
454 impl_stable_hash_for!(enum hir::BindingAnnotation {
461 impl_stable_hash_for!(enum hir::RangeEnd {
466 impl_stable_hash_for!(enum hir::PatKind {
468 Binding(binding_mode, var, name, sub),
469 Struct(path, field_pats, dotdot),
470 TupleStruct(path, field_pats, dotdot),
472 Tuple(field_pats, dotdot),
474 Ref(sub, mutability),
476 Range(start, end, end_kind),
477 Slice(one, two, three)
480 impl_stable_hash_for!(enum hir::BinOp_ {
501 impl_stable_hash_for_spanned!(hir::BinOp_);
503 impl_stable_hash_for!(enum hir::UnOp {
509 impl_stable_hash_for_spanned!(hir::Stmt_);
511 impl_stable_hash_for!(struct hir::Local {
522 impl_stable_hash_for_spanned!(hir::Decl_);
523 impl_stable_hash_for!(enum hir::Decl_ {
528 impl_stable_hash_for!(struct hir::Arm {
535 impl<'a> HashStable<StableHashingContext<'a>> for hir::Field {
536 fn hash_stable<W: StableHasherResult>(&self,
537 hcx: &mut StableHashingContext<'a>,
538 hasher: &mut StableHasher<W>) {
547 ident.hash_stable(hcx, hasher);
548 expr.hash_stable(hcx, hasher);
549 span.hash_stable(hcx, hasher);
550 is_shorthand.hash_stable(hcx, hasher);
554 impl_stable_hash_for_spanned!(ast::Name);
557 impl_stable_hash_for!(enum hir::BlockCheckMode {
560 PushUnsafeBlock(src),
564 impl_stable_hash_for!(enum hir::UnsafeSource {
569 impl_stable_hash_for!(struct hir::AnonConst {
575 impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
576 fn hash_stable<W: StableHasherResult>(&self,
577 hcx: &mut StableHashingContext<'a>,
578 hasher: &mut StableHasher<W>) {
579 hcx.while_hashing_hir_bodies(true, |hcx| {
588 span.hash_stable(hcx, hasher);
589 node.hash_stable(hcx, hasher);
590 attrs.hash_stable(hcx, hasher);
595 impl_stable_hash_for!(enum hir::Expr_ {
598 ExprCall(callee, args),
599 ExprMethodCall(segment, span, args),
601 ExprBinary(op, lhs, rhs),
602 ExprUnary(op, operand),
606 ExprIf(cond, then, els),
607 ExprWhile(cond, body, label),
608 ExprLoop(body, label, loop_src),
609 ExprMatch(matchee, arms, match_src),
610 ExprClosure(capture_clause, decl, body_id, span, gen),
611 ExprBlock(blk, label),
612 ExprAssign(lhs, rhs),
613 ExprAssignOp(op, lhs, rhs),
614 ExprField(owner, ident),
617 ExprAddrOf(mutability, sub),
618 ExprBreak(destination, sub),
619 ExprAgain(destination),
621 ExprInlineAsm(asm, inputs, outputs),
622 ExprStruct(path, fields, base),
623 ExprRepeat(val, times),
627 impl_stable_hash_for!(enum hir::LocalSource {
632 impl_stable_hash_for!(enum hir::LoopSource {
638 impl<'a> HashStable<StableHashingContext<'a>> for hir::MatchSource {
639 fn hash_stable<W: StableHasherResult>(&self,
640 hcx: &mut StableHashingContext<'a>,
641 hasher: &mut StableHasher<W>) {
642 use hir::MatchSource;
644 mem::discriminant(self).hash_stable(hcx, hasher);
646 MatchSource::Normal |
647 MatchSource::WhileLetDesugar |
648 MatchSource::ForLoopDesugar |
649 MatchSource::TryDesugar => {
650 // No fields to hash.
652 MatchSource::IfLetDesugar { contains_else_clause } => {
653 contains_else_clause.hash_stable(hcx, hasher);
659 impl_stable_hash_for!(enum hir::GeneratorMovability {
664 impl_stable_hash_for!(enum hir::CaptureClause {
669 impl_stable_hash_for_spanned!(usize);
671 impl_stable_hash_for!(struct hir::Destination {
676 impl_stable_hash_for_spanned!(ast::Ident);
678 impl_stable_hash_for!(enum hir::LoopIdError {
680 UnlabeledCfInWhileCondition,
684 impl<'a> HashStable<StableHashingContext<'a>> for ast::Ident {
685 fn hash_stable<W: StableHasherResult>(&self,
686 hcx: &mut StableHashingContext<'a>,
687 hasher: &mut StableHasher<W>) {
693 name.hash_stable(hcx, hasher);
694 span.hash_stable(hcx, hasher);
698 impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
699 fn hash_stable<W: StableHasherResult>(&self,
700 hcx: &mut StableHashingContext<'a>,
701 hasher: &mut StableHasher<W>) {
712 hcx.hash_hir_item_like(|hcx| {
713 name.hash_stable(hcx, hasher);
714 attrs.hash_stable(hcx, hasher);
715 generics.hash_stable(hcx, hasher);
716 node.hash_stable(hcx, hasher);
717 span.hash_stable(hcx, hasher);
722 impl_stable_hash_for!(enum hir::TraitMethod {
727 impl_stable_hash_for!(enum hir::TraitItemKind {
733 impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
734 fn hash_stable<W: StableHasherResult>(&self,
735 hcx: &mut StableHashingContext<'a>,
736 hasher: &mut StableHasher<W>) {
749 hcx.hash_hir_item_like(|hcx| {
750 name.hash_stable(hcx, hasher);
751 vis.hash_stable(hcx, hasher);
752 defaultness.hash_stable(hcx, hasher);
753 attrs.hash_stable(hcx, hasher);
754 generics.hash_stable(hcx, hasher);
755 node.hash_stable(hcx, hasher);
756 span.hash_stable(hcx, hasher);
761 impl_stable_hash_for!(enum hir::ImplItemKind {
767 impl_stable_hash_for!(enum ::syntax::ast::CrateSugar {
772 impl<'a> HashStable<StableHashingContext<'a>> for hir::Visibility {
773 fn hash_stable<W: StableHasherResult>(&self,
774 hcx: &mut StableHashingContext<'a>,
775 hasher: &mut StableHasher<W>) {
776 mem::discriminant(self).hash_stable(hcx, hasher);
778 hir::Visibility::Public |
779 hir::Visibility::Inherited => {
780 // No fields to hash.
782 hir::Visibility::Crate(sugar) => {
783 sugar.hash_stable(hcx, hasher);
785 hir::Visibility::Restricted { ref path, id } => {
786 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
787 id.hash_stable(hcx, hasher);
789 path.hash_stable(hcx, hasher);
795 impl<'a> HashStable<StableHashingContext<'a>> for hir::Defaultness {
796 fn hash_stable<W: StableHasherResult>(&self,
797 hcx: &mut StableHashingContext<'a>,
798 hasher: &mut StableHasher<W>) {
799 mem::discriminant(self).hash_stable(hcx, hasher);
801 hir::Defaultness::Final => {
802 // No fields to hash.
804 hir::Defaultness::Default { has_value } => {
805 has_value.hash_stable(hcx, hasher);
811 impl_stable_hash_for!(enum hir::ImplPolarity {
816 impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
817 fn hash_stable<W: StableHasherResult>(&self,
818 hcx: &mut StableHashingContext<'a>,
819 hasher: &mut StableHasher<W>) {
822 // We are not hashing the IDs of the items contained in the module.
823 // This is harmless and matches the current behavior but it's not
824 // actually correct. See issue #40876.
828 inner.hash_stable(hcx, hasher);
832 impl_stable_hash_for!(struct hir::ForeignMod {
837 impl_stable_hash_for!(struct hir::EnumDef {
841 impl_stable_hash_for!(struct hir::Variant_ {
848 impl_stable_hash_for_spanned!(hir::Variant_);
850 impl_stable_hash_for!(enum hir::UseKind {
856 impl_stable_hash_for!(struct hir::StructField {
865 impl_stable_hash_for!(enum hir::VariantData {
871 impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
872 fn hash_stable<W: StableHasherResult>(&self,
873 hcx: &mut StableHashingContext<'a>,
874 hasher: &mut StableHasher<W>) {
885 hcx.hash_hir_item_like(|hcx| {
886 name.hash_stable(hcx, hasher);
887 attrs.hash_stable(hcx, hasher);
888 node.hash_stable(hcx, hasher);
889 vis.hash_stable(hcx, hasher);
890 span.hash_stable(hcx, hasher);
895 impl_stable_hash_for!(enum hir::Item_ {
896 ItemExternCrate(orig_name),
897 ItemUse(path, use_kind),
898 ItemStatic(ty, mutability, body_id),
899 ItemConst(ty, body_id),
900 ItemFn(fn_decl, unsafety, constness, abi, generics, body_id),
902 ItemForeignMod(foreign_mod),
903 ItemGlobalAsm(global_asm),
904 ItemTy(ty, generics),
905 ItemExistential(exist),
906 ItemEnum(enum_def, generics),
907 ItemStruct(variant_data, generics),
908 ItemUnion(variant_data, generics),
909 ItemTrait(is_auto, unsafety, generics, bounds, item_refs),
910 ItemTraitAlias(generics, bounds),
911 ItemImpl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs)
914 impl_stable_hash_for!(struct hir::TraitItemRef {
922 impl_stable_hash_for!(struct hir::ImplItemRef {
931 impl<'a> HashStable<StableHashingContext<'a>>
932 for hir::AssociatedItemKind {
933 fn hash_stable<W: StableHasherResult>(&self,
934 hcx: &mut StableHashingContext<'a>,
935 hasher: &mut StableHasher<W>) {
936 mem::discriminant(self).hash_stable(hcx, hasher);
938 hir::AssociatedItemKind::Const |
939 hir::AssociatedItemKind::Type => {
940 // No fields to hash.
942 hir::AssociatedItemKind::Method { has_self } => {
943 has_self.hash_stable(hcx, hasher);
949 impl_stable_hash_for!(struct hir::ForeignItem {
958 impl_stable_hash_for!(enum hir::ForeignItem_ {
959 ForeignItemFn(fn_decl, arg_names, generics),
960 ForeignItemStatic(ty, is_mutbl),
964 impl_stable_hash_for!(enum hir::Stmt_ {
970 impl_stable_hash_for!(struct hir::Arg {
976 impl<'a> HashStable<StableHashingContext<'a>> for hir::Body {
977 fn hash_stable<W: StableHasherResult>(&self,
978 hcx: &mut StableHashingContext<'a>,
979 hasher: &mut StableHasher<W>) {
986 hcx.with_node_id_hashing_mode(NodeIdHashingMode::Ignore, |hcx| {
987 arguments.hash_stable(hcx, hasher);
988 value.hash_stable(hcx, hasher);
989 is_generator.hash_stable(hcx, hasher);
994 impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::BodyId {
995 type KeyType = (DefPathHash, hir::ItemLocalId);
998 fn to_stable_hash_key(&self,
999 hcx: &StableHashingContext<'a>)
1000 -> (DefPathHash, hir::ItemLocalId) {
1001 let hir::BodyId { node_id } = *self;
1002 node_id.to_stable_hash_key(hcx)
1006 impl_stable_hash_for!(struct hir::InlineAsmOutput {
1012 impl<'a> HashStable<StableHashingContext<'a>> for hir::GlobalAsm {
1013 fn hash_stable<W: StableHasherResult>(&self,
1014 hcx: &mut StableHashingContext<'a>,
1015 hasher: &mut StableHasher<W>) {
1016 let hir::GlobalAsm {
1021 asm.hash_stable(hcx, hasher);
1025 impl<'a> HashStable<StableHashingContext<'a>> for hir::InlineAsm {
1026 fn hash_stable<W: StableHasherResult>(&self,
1027 hcx: &mut StableHashingContext<'a>,
1028 hasher: &mut StableHasher<W>) {
1029 let hir::InlineAsm {
1038 ctxt: _, // This is used for error reporting
1041 asm.hash_stable(hcx, hasher);
1042 asm_str_style.hash_stable(hcx, hasher);
1043 outputs.hash_stable(hcx, hasher);
1044 inputs.hash_stable(hcx, hasher);
1045 clobbers.hash_stable(hcx, hasher);
1046 volatile.hash_stable(hcx, hasher);
1047 alignstack.hash_stable(hcx, hasher);
1048 dialect.hash_stable(hcx, hasher);
1052 impl_stable_hash_for!(enum hir::def::CtorKind {
1058 impl_stable_hash_for!(enum hir::def::Def {
1063 Existential(def_id),
1068 AssociatedTy(def_id),
1071 SelfTy(trait_def_id, impl_def_id),
1075 Static(def_id, is_mutbl),
1076 StructCtor(def_id, ctor_kind),
1077 VariantCtor(def_id, ctor_kind),
1079 AssociatedConst(def_id),
1081 Upvar(def_id, index, expr_id),
1083 Macro(def_id, macro_kind),
1088 impl_stable_hash_for!(enum hir::Mutability {
1093 impl_stable_hash_for!(enum hir::IsAuto {
1098 impl_stable_hash_for!(enum hir::Unsafety {
1104 impl_stable_hash_for!(enum hir::Constness {
1109 impl<'a> HashStable<StableHashingContext<'a>>
1110 for hir::def_id::DefIndex {
1112 fn hash_stable<W: StableHasherResult>(&self,
1113 hcx: &mut StableHashingContext<'a>,
1114 hasher: &mut StableHasher<W>) {
1115 hcx.local_def_path_hash(*self).hash_stable(hcx, hasher);
1119 impl<'a> ToStableHashKey<StableHashingContext<'a>>
1120 for hir::def_id::DefIndex {
1121 type KeyType = DefPathHash;
1124 fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
1125 hcx.local_def_path_hash(*self)
1129 impl_stable_hash_for!(struct hir::def::Export {
1136 impl<'a> HashStable<StableHashingContext<'a>>
1137 for ::middle::lang_items::LangItem {
1138 fn hash_stable<W: StableHasherResult>(&self,
1139 _: &mut StableHashingContext<'a>,
1140 hasher: &mut StableHasher<W>) {
1141 ::std::hash::Hash::hash(self, hasher);
1145 impl_stable_hash_for!(struct ::middle::lang_items::LanguageItems {
1150 impl<'a> HashStable<StableHashingContext<'a>>
1151 for hir::TraitCandidate {
1152 fn hash_stable<W: StableHasherResult>(&self,
1153 hcx: &mut StableHashingContext<'a>,
1154 hasher: &mut StableHasher<W>) {
1155 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
1156 let hir::TraitCandidate {
1161 def_id.hash_stable(hcx, hasher);
1162 import_id.hash_stable(hcx, hasher);
1167 impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
1168 type KeyType = (DefPathHash, Option<(DefPathHash, hir::ItemLocalId)>);
1170 fn to_stable_hash_key(&self,
1171 hcx: &StableHashingContext<'a>)
1173 let hir::TraitCandidate {
1178 let import_id = import_id.map(|node_id| hcx.node_to_hir_id(node_id))
1179 .map(|hir_id| (hcx.local_def_path_hash(hir_id.owner),
1181 (hcx.def_path_hash(def_id), import_id)
1185 impl<'hir> HashStable<StableHashingContext<'hir>> for hir::CodegenFnAttrs
1187 fn hash_stable<W: StableHasherResult>(&self,
1188 hcx: &mut StableHashingContext<'hir>,
1189 hasher: &mut StableHasher<W>) {
1190 let hir::CodegenFnAttrs {
1194 ref target_features,
1198 flags.hash_stable(hcx, hasher);
1199 inline.hash_stable(hcx, hasher);
1200 export_name.hash_stable(hcx, hasher);
1201 target_features.hash_stable(hcx, hasher);
1202 linkage.hash_stable(hcx, hasher);
1206 impl<'hir> HashStable<StableHashingContext<'hir>> for hir::CodegenFnAttrFlags
1208 fn hash_stable<W: StableHasherResult>(&self,
1209 hcx: &mut StableHashingContext<'hir>,
1210 hasher: &mut StableHasher<W>) {
1211 self.bits().hash_stable(hcx, hasher);
1215 impl<'hir> HashStable<StableHashingContext<'hir>> for attr::InlineAttr {
1216 fn hash_stable<W: StableHasherResult>(&self,
1217 hcx: &mut StableHashingContext<'hir>,
1218 hasher: &mut StableHasher<W>) {
1219 mem::discriminant(self).hash_stable(hcx, hasher);
1223 impl_stable_hash_for!(struct hir::Freevar {