Return(t)
});
-impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitRef {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::TraitRef {
- ref path,
- // Don't hash the ref_id. It is tracked via the thing it is used to access
- ref_id: _,
- } = *self;
-
- path.hash_stable(hcx, hasher);
- }
-}
-
+impl_stable_hash_for!(struct hir::TraitRef {
+ // Don't hash the ref_id. It is tracked via the thing it is used to access
+ ref_id -> _,
+ path,
+});
impl_stable_hash_for!(struct hir::PolyTraitRef {
bound_generic_params,
body
});
+impl_stable_hash_for!(struct hir::Block {
+ stmts,
+ expr,
+ id -> _,
+ hir_id -> _,
+ rules,
+ span,
+ targeted_by_break,
+ recovered,
+});
-impl<'a> HashStable<StableHashingContext<'a>> for hir::Block {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::Block {
- ref stmts,
- ref expr,
- id: _,
- hir_id: _,
- rules,
- span,
- targeted_by_break,
- recovered,
- } = *self;
-
- stmts.hash_stable(hcx, hasher);
- expr.hash_stable(hcx, hasher);
- rules.hash_stable(hcx, hasher);
- span.hash_stable(hcx, hasher);
- recovered.hash_stable(hcx, hasher);
- targeted_by_break.hash_stable(hcx, hasher);
- }
-}
-
-impl<'a> HashStable<StableHashingContext<'a>> for hir::Pat {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::Pat {
- id: _,
- hir_id: _,
- ref node,
- ref span
- } = *self;
-
-
- node.hash_stable(hcx, hasher);
- span.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::Pat {
+ id -> _,
+ hir_id -> _,
+ node,
+ span,
+});
impl_stable_hash_for_spanned!(hir::FieldPat);
-impl<'a> HashStable<StableHashingContext<'a>> for hir::FieldPat {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::FieldPat {
- id: _,
- ident,
- ref pat,
- is_shorthand,
- } = *self;
-
- ident.hash_stable(hcx, hasher);
- pat.hash_stable(hcx, hasher);
- is_shorthand.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::FieldPat {
+ id -> _,
+ ident,
+ pat,
+ is_shorthand,
+});
impl_stable_hash_for!(enum hir::BindingAnnotation {
Unannotated,
body
});
-impl<'a> HashStable<StableHashingContext<'a>> for hir::Field {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::Field {
- id: _,
- ident,
- ref expr,
- span,
- is_shorthand,
- } = *self;
-
- ident.hash_stable(hcx, hasher);
- expr.hash_stable(hcx, hasher);
- span.hash_stable(hcx, hasher);
- is_shorthand.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::Field {
+ id -> _,
+ ident,
+ expr,
+ span,
+ is_shorthand,
+});
impl_stable_hash_for_spanned!(ast::Name);
UnresolvedLabel
});
-impl<'a> HashStable<StableHashingContext<'a>> for ast::Ident {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ast::Ident {
- name,
- span,
- } = *self;
-
- name.hash_stable(hcx, hasher);
- span.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct ast::Ident {
+ name,
+ span,
+});
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
fn hash_stable<W: StableHasherResult>(&self,
Negative
});
-impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::Mod {
- inner,
- // We are not hashing the IDs of the items contained in the module.
- // This is harmless and matches the current behavior but it's not
- // actually correct. See issue #40876.
- item_ids: _,
- } = *self;
-
- inner.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::Mod {
+ inner,
+ // We are not hashing the IDs of the items contained in the module.
+ // This is harmless and matches the current behavior but it's not
+ // actually correct. See issue #40876.
+ item_ids -> _,
+});
impl_stable_hash_for!(struct hir::ForeignMod {
abi,
defaultness
});
-impl<'a> HashStable<StableHashingContext<'a>>
-for hir::AssociatedItemKind {
+impl<'a> HashStable<StableHashingContext<'a>> for hir::AssociatedItemKind {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
is_indirect
});
-impl<'a> HashStable<StableHashingContext<'a>> for hir::GlobalAsm {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::GlobalAsm {
- asm,
- ctxt: _
- } = *self;
-
- asm.hash_stable(hcx, hasher);
- }
-}
-
-impl<'a> HashStable<StableHashingContext<'a>> for hir::InlineAsm {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let hir::InlineAsm {
- asm,
- asm_str_style,
- ref outputs,
- ref inputs,
- ref clobbers,
- volatile,
- alignstack,
- dialect,
- ctxt: _, // This is used for error reporting
- } = *self;
+impl_stable_hash_for!(struct hir::GlobalAsm {
+ asm,
+ ctxt -> _, // This is used for error reporting
+});
- asm.hash_stable(hcx, hasher);
- asm_str_style.hash_stable(hcx, hasher);
- outputs.hash_stable(hcx, hasher);
- inputs.hash_stable(hcx, hasher);
- clobbers.hash_stable(hcx, hasher);
- volatile.hash_stable(hcx, hasher);
- alignstack.hash_stable(hcx, hasher);
- dialect.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::InlineAsm {
+ asm,
+ asm_str_style,
+ outputs,
+ inputs,
+ clobbers,
+ volatile,
+ alignstack,
+ dialect,
+ ctxt -> _, // This is used for error reporting
+});
impl_stable_hash_for!(enum hir::def::CtorKind {
Fn,
NotConst
});
-impl<'a> HashStable<StableHashingContext<'a>>
-for hir::def_id::DefIndex {
+impl<'a> HashStable<StableHashingContext<'a>> for hir::def_id::DefIndex {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
span
});
-impl<'a> HashStable<StableHashingContext<'a>>
-for ::middle::lang_items::LangItem {
+impl<'a> HashStable<StableHashingContext<'a>> for ::middle::lang_items::LangItem {
fn hash_stable<W: StableHasherResult>(&self,
_: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
missing
});
-impl<'a> HashStable<StableHashingContext<'a>>
-for hir::TraitCandidate {
+impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
}
}
-impl<'hir> HashStable<StableHashingContext<'hir>> for hir::CodegenFnAttrs
-{
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'hir>,
- hasher: &mut StableHasher<W>) {
- let hir::CodegenFnAttrs {
- flags,
- inline,
- export_name,
- ref target_features,
- linkage,
- } = *self;
-
- flags.hash_stable(hcx, hasher);
- inline.hash_stable(hcx, hasher);
- export_name.hash_stable(hcx, hasher);
- target_features.hash_stable(hcx, hasher);
- linkage.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct hir::CodegenFnAttrs {
+ flags,
+ inline,
+ export_name,
+ target_features,
+ linkage,
+});
impl<'hir> HashStable<StableHashingContext<'hir>> for hir::CodegenFnAttrFlags
{
Relative(distance)
});
-impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::FieldDef {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ty::FieldDef { did, ident, vis } = *self;
-
- did.hash_stable(hcx, hasher);
- ident.name.hash_stable(hcx, hasher);
- vis.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct ty::FieldDef {
+ did,
+ ident -> (ident.name),
+ vis,
+});
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ::middle::const_val::ConstVal<'gcx> {
predicates
});
-
-impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
-for ::mir::interpret::EvalError<'gcx> {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- self.kind.hash_stable(hcx, hasher)
- }
-}
+impl_stable_hash_for!(struct ::mir::interpret::EvalError<'tcx> { kind });
impl<'a, 'gcx, O: HashStable<StableHashingContext<'a>>> HashStable<StableHashingContext<'a>>
for ::mir::interpret::EvalErrorKind<'gcx, O> {
Struct(index)
});
-impl<'a> HashStable<StableHashingContext<'a>> for ty::Generics {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ty::Generics {
- parent,
- ref parent_count,
- ref params,
-
- // Reverse map to each param's `index` field, from its `def_id`.
- param_def_id_to_index: _, // Don't hash this
- has_self,
- has_late_bound_regions,
- } = *self;
-
- parent.hash_stable(hcx, hasher);
- parent_count.hash_stable(hcx, hasher);
- params.hash_stable(hcx, hasher);
- has_self.hash_stable(hcx, hasher);
- has_late_bound_regions.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct ty::Generics {
+ parent,
+ parent_count,
+ params,
+ // Reverse map to each param's `index` field, from its `def_id`.
+ param_def_id_to_index -> _, // Don't hash this
+ has_self,
+ has_late_bound_regions,
+});
impl_stable_hash_for!(struct ty::GenericParamDef {
name,
}
}
-impl<'a> HashStable<StableHashingContext<'a>> for ty::TraitDef {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ty::TraitDef {
- // We already have the def_path_hash below, no need to hash it twice
- def_id: _,
- unsafety,
- paren_sugar,
- has_auto_impl,
- def_path_hash,
- } = *self;
-
- unsafety.hash_stable(hcx, hasher);
- paren_sugar.hash_stable(hcx, hasher);
- has_auto_impl.hash_stable(hcx, hasher);
- def_path_hash.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct ty::TraitDef {
+ // We already have the def_path_hash below, no need to hash it twice
+ def_id -> _,
+ unsafety,
+ paren_sugar,
+ has_auto_impl,
+ def_path_hash,
+});
impl_stable_hash_for!(struct ty::Destructor {
did
});
-impl<'a> HashStable<StableHashingContext<'a>> for ty::CrateVariancesMap {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ty::CrateVariancesMap {
- ref variances,
- // This is just an irrelevant helper value.
- empty_variance: _,
- } = *self;
-
- variances.hash_stable(hcx, hasher);
- }
-}
-
-impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::CratePredicatesMap<'gcx> {
- fn hash_stable<W: StableHasherResult>(&self,
- hcx: &mut StableHashingContext<'a>,
- hasher: &mut StableHasher<W>) {
- let ty::CratePredicatesMap {
- ref predicates,
- // This is just an irrelevant helper value.
- empty_predicate: _,
- } = *self;
+impl_stable_hash_for!(struct ty::CrateVariancesMap {
+ variances,
+ // This is just an irrelevant helper value.
+ empty_variance -> _,
+});
- predicates.hash_stable(hcx, hasher);
- }
-}
+impl_stable_hash_for!(struct ty::CratePredicatesMap<'tcx> {
+ predicates,
+ // This is just an irrelevant helper value.
+ empty_predicate -> _,
+});
impl_stable_hash_for!(struct ty::AssociatedItem {
def_id,
#[macro_export]
macro_rules! __impl_stable_hash_field {
- (DECL IGNORED) => (_);
- (DECL $name:ident) => (ref $name);
- (USE IGNORED $ctx:expr, $hasher:expr) => ({});
- (USE $name:ident, $ctx:expr, $hasher:expr) => ($name.hash_stable($ctx, $hasher));
+ ($field:ident, $ctx:expr, $hasher:expr) => ($field.hash_stable($ctx, $hasher));
+ ($field:ident, $ctx:expr, $hasher:expr, _) => ({ let _ = $field; });
+ ($field:ident, $ctx:expr, $hasher:expr, $delegate:expr) => ($delegate.hash_stable($ctx, $hasher));
}
#[macro_export]
macro_rules! impl_stable_hash_for {
- (enum $enum_name:path { $( $variant:ident $( ( $($arg:ident),* ) )* ),* $(,)* }) => {
+ (enum $enum_name:path { $( $variant:ident $( ( $($field:ident $(-> $delegate:tt)?),* ) )* ),* $(,)? }) => {
impl<'a, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $enum_name {
#[inline]
fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
match *self {
$(
- $variant $( ( $( __impl_stable_hash_field!(DECL $arg) ),* ) )* => {
- $($( __impl_stable_hash_field!(USE $arg, __ctx, __hasher) );*)*
+ $variant $( ( $(ref $field),* ) )* => {
+ $($( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*)*
}
)*
}
}
}
};
- (struct $struct_name:path { $($field:ident),* }) => {
+ (struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
impl<'a, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name {
#[inline]
fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
$(ref $field),*
} = *self;
- $( $field.hash_stable(__ctx, __hasher));*
+ $( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
}
}
};
- (tuple_struct $struct_name:path { $($field:ident),* }) => {
+ (tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
impl<'a, 'tcx> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name {
#[inline]
fn hash_stable<W: ::rustc_data_structures::stable_hasher::StableHasherResult>(&self,
$(ref $field),*
) = *self;
- $( $field.hash_stable(__ctx, __hasher));*
+ $( __impl_stable_hash_field!($field, __ctx, __hasher $(, $delegate)?) );*
}
}
};