Skip to main content

rustc_middle/ich/
impls_syntax.rs

1//! This module contains `HashStable` implementations for various data types
2//! from various crates in no particular order.
3
4use rustc_ast as ast;
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6
7use super::StableHashingContext;
8
9impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
10    #[inline]
11    fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
12        {
    ::core::panicking::panic_fmt(format_args!("Node IDs should not appear in incremental state"));
};panic!("Node IDs should not appear in incremental state");
13    }
14}
15
16impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::Features {
17    fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
18        // Unfortunately we cannot exhaustively list fields here, since the
19        // struct has private fields (to ensure its invariant is maintained)
20        self.enabled_lang_features().hash_stable(hcx, hasher);
21        self.enabled_lib_features().hash_stable(hcx, hasher);
22    }
23}
24
25impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::EnabledLangFeature {
26    fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
27        let rustc_feature::EnabledLangFeature { gate_name, attr_sp, stable_since } = self;
28        gate_name.hash_stable(hcx, hasher);
29        attr_sp.hash_stable(hcx, hasher);
30        stable_since.hash_stable(hcx, hasher);
31    }
32}
33
34impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::EnabledLibFeature {
35    fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
36        let rustc_feature::EnabledLibFeature { gate_name, attr_sp } = self;
37        gate_name.hash_stable(hcx, hasher);
38        attr_sp.hash_stable(hcx, hasher);
39    }
40}