]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_query_system/src/ich/impls_hir.rs
Rollup merge of #102857 - saethlin:derived-enum-hash-test, r=Mark-Simulacrum
[rust.git] / compiler / rustc_query_system / src / ich / impls_hir.rs
1 //! This module contains `HashStable` implementations for various HIR data
2 //! types in no particular order.
3
4 use crate::ich::hcx::BodyResolver;
5 use crate::ich::StableHashingContext;
6 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
7 use rustc_hir as hir;
8
9 impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
10     #[inline]
11     fn hash_body_id(&mut self, id: hir::BodyId, hasher: &mut StableHasher) {
12         let hcx = self;
13         match hcx.body_resolver {
14             BodyResolver::Forbidden => panic!("Hashing HIR bodies is forbidden."),
15             BodyResolver::Ignore => {}
16             BodyResolver::Traverse { owner, bodies } => {
17                 assert_eq!(id.hir_id.owner, owner);
18                 bodies[&id.hir_id.local_id].hash_stable(hcx, hasher);
19             }
20         }
21     }
22 }