]> git.lizzy.rs Git - rust.git/commitdiff
Hash spans when interning.
authorCamille GILLOT <gillot.camille@gmail.com>
Fri, 11 Nov 2022 12:10:09 +0000 (12:10 +0000)
committerCamille GILLOT <gillot.camille@gmail.com>
Fri, 11 Nov 2022 13:02:37 +0000 (13:02 +0000)
compiler/rustc_data_structures/src/intern.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_query_system/src/ich/hcx.rs

index 009b5d5340afe3c724950d881014d6e716b75c62..8c94ce29b42174ea9f25fb7eea8388b58b52c1de 100644 (file)
@@ -110,11 +110,6 @@ fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
     }
 }
 
-/// A helper trait so that `Interned` things can cache stable hashes reproducibly.
-pub trait InternedHashingContext {
-    fn with_def_path_and_no_spans(&mut self, f: impl FnOnce(&mut Self));
-}
-
 /// A helper type that you can wrap round your own type in order to automatically
 /// cache the stable hash on creation and not recompute it whenever the stable hash
 /// of the type is computed.
@@ -165,7 +160,7 @@ fn hash<H: Hasher>(&self, s: &mut H) {
     }
 }
 
-impl<T: HashStable<CTX>, CTX: InternedHashingContext> HashStable<CTX> for WithStableHash<T> {
+impl<T: HashStable<CTX>, CTX> HashStable<CTX> for WithStableHash<T> {
     fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
         if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) {
             // No cached hash available. This can only mean that incremental is disabled.
@@ -176,7 +171,7 @@ fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
             // otherwise the hashes will differ between cached and non-cached mode.
             let stable_hash: Fingerprint = {
                 let mut hasher = StableHasher::new();
-                hcx.with_def_path_and_no_spans(|hcx| self.internee.hash_stable(hcx, &mut hasher));
+                self.internee.hash_stable(hcx, &mut hasher);
                 hasher.finish()
             };
             if cfg!(debug_assertions) && self.stable_hash != Fingerprint::ZERO {
index 2a93df771e1e225c23028c0412a32442a65473b8..8f96f5a9eb3e99b3e8db919853a31c4c5aff0b0b 100644 (file)
@@ -198,12 +198,8 @@ fn intern_ty(
                         Fingerprint::ZERO
                     } else {
                         let mut hasher = StableHasher::new();
-                        let mut hcx = StableHashingContext::ignore_spans(
-                            sess,
-                            definitions,
-                            cstore,
-                            source_span,
-                        );
+                        let mut hcx =
+                            StableHashingContext::new(sess, definitions, cstore, source_span);
                         kind.hash_stable(&mut hcx, &mut hasher);
                         hasher.finish()
                     };
index 148eabb38e2303692f687517d1cc22df43bcaaa1..6378ec10875d038e087236d195810b573ff6c48b 100644 (file)
@@ -49,15 +49,13 @@ pub(super) enum BodyResolver<'tcx> {
 
 impl<'a> StableHashingContext<'a> {
     #[inline]
-    fn new_with_or_without_spans(
+    pub fn new(
         sess: &'a Session,
         definitions: &'a Definitions,
         cstore: &'a dyn CrateStore,
         source_span: &'a IndexVec<LocalDefId, Span>,
-        always_ignore_spans: bool,
     ) -> Self {
-        let hash_spans_initial =
-            !always_ignore_spans && !sess.opts.unstable_opts.incremental_ignore_spans;
+        let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
 
         StableHashingContext {
             body_resolver: BodyResolver::Forbidden,
@@ -71,33 +69,6 @@ fn new_with_or_without_spans(
         }
     }
 
-    #[inline]
-    pub fn new(
-        sess: &'a Session,
-        definitions: &'a Definitions,
-        cstore: &'a dyn CrateStore,
-        source_span: &'a IndexVec<LocalDefId, Span>,
-    ) -> Self {
-        Self::new_with_or_without_spans(
-            sess,
-            definitions,
-            cstore,
-            source_span,
-            /*always_ignore_spans=*/ false,
-        )
-    }
-
-    #[inline]
-    pub fn ignore_spans(
-        sess: &'a Session,
-        definitions: &'a Definitions,
-        cstore: &'a dyn CrateStore,
-        source_span: &'a IndexVec<LocalDefId, Span>,
-    ) -> Self {
-        let always_ignore_spans = true;
-        Self::new_with_or_without_spans(sess, definitions, cstore, source_span, always_ignore_spans)
-    }
-
     #[inline]
     pub fn without_hir_bodies(&mut self, f: impl FnOnce(&mut StableHashingContext<'_>)) {
         f(&mut StableHashingContext { body_resolver: BodyResolver::Ignore, ..self.clone() });
@@ -202,10 +173,4 @@ fn hashing_controls(&self) -> HashingControls {
     }
 }
 
-impl<'a> rustc_data_structures::intern::InternedHashingContext for StableHashingContext<'a> {
-    fn with_def_path_and_no_spans(&mut self, f: impl FnOnce(&mut Self)) {
-        self.while_hashing_spans(false, f);
-    }
-}
-
 impl<'a> rustc_session::HashStableContext for StableHashingContext<'a> {}