Skip to content

Commit 643e71e

Browse files
committed
Remove the IGNORED_ATTR_NAMES thread local
1 parent 8d3e93b commit 643e71e

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/librustc/ich/hcx.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use session::Session;
1919

2020
use std::cmp::Ord;
2121
use std::hash as std_hash;
22-
use std::cell::RefCell;
2322
use std::collections::HashMap;
23+
use std::cell::RefCell;
2424

2525
use syntax::ast;
2626

@@ -36,8 +36,10 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHashingContextProvi
3636
use rustc_data_structures::accumulate_vec::AccumulateVec;
3737
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
3838

39-
thread_local!(static IGNORED_ATTR_NAMES: RefCell<FxHashSet<Symbol>> =
40-
RefCell::new(FxHashSet()));
39+
pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
40+
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
41+
ich::IGNORED_ATTRIBUTES.iter().map(|&s| Symbol::intern(s)).collect()
42+
}
4143

4244
/// This is the context state available during incr. comp. hashing. It contains
4345
/// enough information to transform DefIds and HirIds into stable DefPaths (i.e.
@@ -90,15 +92,6 @@ impl<'gcx> StableHashingContext<'gcx> {
9092
-> Self {
9193
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;
9294

93-
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
94-
IGNORED_ATTR_NAMES.with(|names| {
95-
let mut names = names.borrow_mut();
96-
if names.is_empty() {
97-
names.extend(ich::IGNORED_ATTRIBUTES.iter()
98-
.map(|&s| Symbol::intern(s)));
99-
}
100-
});
101-
10295
StableHashingContext {
10396
sess,
10497
body_resolver: BodyResolver(krate),
@@ -186,9 +179,7 @@ impl<'gcx> StableHashingContext<'gcx> {
186179

187180
#[inline]
188181
pub fn is_ignored_attr(&self, name: Symbol) -> bool {
189-
IGNORED_ATTR_NAMES.with(|names| {
190-
names.borrow().contains(&name)
191-
})
182+
self.sess.ignored_attr_names.contains(&name)
192183
}
193184

194185
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
pub use self::fingerprint::Fingerprint;
1414
pub use self::caching_codemap_view::CachingCodemapView;
1515
pub use self::hcx::{StableHashingContext, NodeIdHashingMode,
16-
hash_stable_trait_impls};
16+
hash_stable_trait_impls, compute_ignored_attr_names};
1717
mod fingerprint;
1818
mod caching_codemap_view;
1919
mod hcx;

src/librustc/session/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};
1414
use hir::def_id::CrateNum;
1515
use ich::Fingerprint;
1616

17+
use ich;
1718
use lint;
1819
use middle::allocator::AllocatorKind;
1920
use middle::dependency_format;
@@ -28,6 +29,7 @@ use errors::{self, DiagnosticBuilder, DiagnosticId};
2829
use errors::emitter::{Emitter, EmitterWriter};
2930
use syntax::json::JsonEmitter;
3031
use syntax::feature_gate;
32+
use syntax::symbol::Symbol;
3133
use syntax::parse;
3234
use syntax::parse::ParseSess;
3335
use syntax::{ast, codemap};
@@ -112,6 +114,9 @@ pub struct Session {
112114

113115
incr_comp_session: RefCell<IncrCompSession>,
114116

117+
/// A cache of attributes ignored by StableHashingContext
118+
pub ignored_attr_names: FxHashSet<Symbol>,
119+
115120
/// Some measurements that are being gathered during compilation.
116121
pub perf_stats: PerfStats,
117122

@@ -975,6 +980,7 @@ pub fn build_session_(sopts: config::Options,
975980
injected_panic_runtime: Cell::new(None),
976981
imported_macro_spans: RefCell::new(HashMap::new()),
977982
incr_comp_session: RefCell::new(IncrCompSession::NotInitialized),
983+
ignored_attr_names: ich::compute_ignored_attr_names(),
978984
perf_stats: PerfStats {
979985
svh_time: Cell::new(Duration::from_secs(0)),
980986
incr_comp_hashes_time: Cell::new(Duration::from_secs(0)),

0 commit comments

Comments
 (0)