Cache ignored attributes inside ICH entirely

This commit is contained in:
Mark Rousskov 2018-08-03 18:39:28 -06:00
parent bd6fe1e700
commit ed246fcc95
3 changed files with 6 additions and 9 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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 {