about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-08-03 18:39:28 -0600
committerMark Rousskov <mark.simulacrum@gmail.com>2018-08-09 10:00:25 -0600
commited246fcc953831b50ec0fb5b26a48d0704a15ed7 (patch)
tree4d180fa589d44ed0fad664af47afc85cbf0539a5
parentbd6fe1e7007c110d3afa46a2c0df14eb07df372e (diff)
downloadrust-ed246fcc953831b50ec0fb5b26a48d0704a15ed7.tar.gz
rust-ed246fcc953831b50ec0fb5b26a48d0704a15ed7.zip
Cache ignored attributes inside ICH entirely
-rw-r--r--src/librustc/ich/hcx.rs7
-rw-r--r--src/librustc/ich/mod.rs2
-rw-r--r--src/librustc/session/mod.rs6
3 files changed, 6 insertions, 9 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 05361b65641..329cc2216a4 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -37,7 +37,7 @@ use rustc_data_structures::stable_hasher::{HashStable,
 use rustc_data_structures::accumulate_vec::AccumulateVec;
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
 
-pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
+fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
     debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
     ich::IGNORED_ATTRIBUTES.iter().map(|&s| Symbol::intern(s)).collect()
 }
@@ -183,7 +183,10 @@ impl<'a> StableHashingContext<'a> {
 
     #[inline]
     pub fn is_ignored_attr(&self, name: Symbol) -> bool {
-        self.sess.ignored_attr_names.contains(&name)
+        thread_local! {
+            static IGNORED_ATTRIBUTES: FxHashSet<Symbol> = compute_ignored_attr_names();
+        }
+        IGNORED_ATTRIBUTES.with(|attrs| attrs.contains(&name))
     }
 
     pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {
diff --git a/src/librustc/ich/mod.rs b/src/librustc/ich/mod.rs
index dbb9ecaddfd..b00d8c56569 100644
--- a/src/librustc/ich/mod.rs
+++ b/src/librustc/ich/mod.rs
@@ -13,7 +13,7 @@
 crate use rustc_data_structures::fingerprint::Fingerprint;
 pub use self::caching_codemap_view::CachingCodemapView;
 pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
-                    hash_stable_trait_impls, compute_ignored_attr_names};
+                    hash_stable_trait_impls};
 mod caching_codemap_view;
 mod hcx;
 
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index ece58978c5d..c3d4d3abf9a 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -14,7 +14,6 @@ use self::code_stats::CodeStats;
 use hir::def_id::CrateNum;
 use rustc_data_structures::fingerprint::Fingerprint;
 
-use ich;
 use lint;
 use lint::builtin::BuiltinLintDiagnostics;
 use middle::allocator::AllocatorKind;
@@ -34,7 +33,6 @@ use errors::emitter::{Emitter, EmitterWriter};
 use syntax::edition::Edition;
 use syntax::json::JsonEmitter;
 use syntax::feature_gate;
-use syntax::symbol::Symbol;
 use syntax::parse;
 use syntax::parse::ParseSess;
 use syntax::{ast, codemap};
@@ -128,9 +126,6 @@ pub struct Session {
 
     incr_comp_session: OneThread<RefCell<IncrCompSession>>,
 
-    /// A cache of attributes ignored by StableHashingContext
-    pub ignored_attr_names: FxHashSet<Symbol>,
-
     /// Used by -Z profile-queries in util::common
     pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,
 
@@ -1143,7 +1138,6 @@ pub fn build_session_(
         injected_panic_runtime: Once::new(),
         imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
         incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
-        ignored_attr_names: ich::compute_ignored_attr_names(),
         self_profiling: Lock::new(SelfProfiler::new()),
         profile_channel: Lock::new(None),
         perf_stats: PerfStats {