Skip to content

Commit ed246fc

Browse files
Cache ignored attributes inside ICH entirely
1 parent bd6fe1e commit ed246fc

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/librustc/ich/hcx.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use rustc_data_structures::stable_hasher::{HashStable,
3737
use rustc_data_structures::accumulate_vec::AccumulateVec;
3838
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
3939

40-
pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
40+
fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
4141
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
4242
ich::IGNORED_ATTRIBUTES.iter().map(|&s| Symbol::intern(s)).collect()
4343
}
@@ -183,7 +183,10 @@ impl<'a> StableHashingContext<'a> {
183183

184184
#[inline]
185185
pub fn is_ignored_attr(&self, name: Symbol) -> bool {
186-
self.sess.ignored_attr_names.contains(&name)
186+
thread_local! {
187+
static IGNORED_ATTRIBUTES: FxHashSet<Symbol> = compute_ignored_attr_names();
188+
}
189+
IGNORED_ATTRIBUTES.with(|attrs| attrs.contains(&name))
187190
}
188191

189192
pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {

src/librustc/ich/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
crate use rustc_data_structures::fingerprint::Fingerprint;
1414
pub use self::caching_codemap_view::CachingCodemapView;
1515
pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
16-
hash_stable_trait_impls, compute_ignored_attr_names};
16+
hash_stable_trait_impls};
1717
mod caching_codemap_view;
1818
mod hcx;
1919

src/librustc/session/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use self::code_stats::CodeStats;
1414
use hir::def_id::CrateNum;
1515
use rustc_data_structures::fingerprint::Fingerprint;
1616

17-
use ich;
1817
use lint;
1918
use lint::builtin::BuiltinLintDiagnostics;
2019
use middle::allocator::AllocatorKind;
@@ -34,7 +33,6 @@ use errors::emitter::{Emitter, EmitterWriter};
3433
use syntax::edition::Edition;
3534
use syntax::json::JsonEmitter;
3635
use syntax::feature_gate;
37-
use syntax::symbol::Symbol;
3836
use syntax::parse;
3937
use syntax::parse::ParseSess;
4038
use syntax::{ast, codemap};
@@ -128,9 +126,6 @@ pub struct Session {
128126

129127
incr_comp_session: OneThread<RefCell<IncrCompSession>>,
130128

131-
/// A cache of attributes ignored by StableHashingContext
132-
pub ignored_attr_names: FxHashSet<Symbol>,
133-
134129
/// Used by -Z profile-queries in util::common
135130
pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,
136131

@@ -1143,7 +1138,6 @@ pub fn build_session_(
11431138
injected_panic_runtime: Once::new(),
11441139
imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
11451140
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
1146-
ignored_attr_names: ich::compute_ignored_attr_names(),
11471141
self_profiling: Lock::new(SelfProfiler::new()),
11481142
profile_channel: Lock::new(None),
11491143
perf_stats: PerfStats {

0 commit comments

Comments
 (0)