Skip to content

Commit

Permalink
Cache ignored attributes inside ICH entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 9, 2018
1 parent bd6fe1e commit ed246fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/librustc/ich/hcx.rs
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/mod.rs
Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions src/librustc/session/mod.rs
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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>>>,

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ed246fc

Please sign in to comment.