Improve query efficiency
This commit is contained in:
parent
e5d5e6a560
commit
bd90137b94
6 changed files with 11 additions and 12 deletions
src
librustc
librustc_metadata
|
@ -615,7 +615,7 @@ define_dep_nodes!( <'tcx>
|
|||
[input] CrateName(CrateNum),
|
||||
[] ItemChildren(DefId),
|
||||
[] ExternModStmtCnum(DefId),
|
||||
[input] GetLibFeatures,
|
||||
[eval_always] GetLibFeatures,
|
||||
[] DefinedLibFeatures(CrateNum),
|
||||
[eval_always] GetLangItems,
|
||||
[] DefinedLangItems(CrateNum),
|
||||
|
|
|
@ -37,10 +37,12 @@ impl LibFeatures {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> Vec<(Symbol, Option<Symbol>)> {
|
||||
self.stable.iter().map(|(f, s)| (*f, Some(*s)))
|
||||
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
|
||||
let mut all_features: Vec<_> = self.stable.iter().map(|(f, s)| (*f, Some(*s)))
|
||||
.chain(self.unstable.iter().map(|f| (*f, None)))
|
||||
.collect()
|
||||
.collect();
|
||||
all_features.sort_unstable_by_key(|f| f.0.as_str());
|
||||
all_features
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -841,7 +841,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
|||
// FIXME: only remove `libc` when `stdbuild` is active.
|
||||
remaining_lib_features.remove(&Symbol::intern("libc"));
|
||||
|
||||
for (feature, stable) in tcx.lib_features().iter() {
|
||||
for (feature, stable) in tcx.lib_features().to_vec() {
|
||||
if let Some(since) = stable {
|
||||
if let Some(span) = remaining_lib_features.get(&feature) {
|
||||
// Warn if the user has enabled an already-stable lib feature.
|
||||
|
|
|
@ -2846,8 +2846,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
|||
};
|
||||
providers.get_lib_features = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
// FIXME(#42293): see comment below.
|
||||
tcx.dep_graph.with_ignore(|| Lrc::new(middle::lib_features::collect(tcx)))
|
||||
Lrc::new(middle::lib_features::collect(tcx))
|
||||
};
|
||||
providers.get_lang_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
|
|
|
@ -647,12 +647,10 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
|
||||
/// Iterates over all the stability attributes in the given crate.
|
||||
pub fn get_lib_features(&self) -> Vec<(ast::Name, Option<ast::Name>)> {
|
||||
let mut features: Vec<_> = self.root
|
||||
self.root
|
||||
.lib_features
|
||||
.decode(self)
|
||||
.collect();
|
||||
features.sort_unstable_by_key(|f| f.0.as_str());
|
||||
features
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Iterates over the language items in the given crate.
|
||||
|
|
|
@ -1466,7 +1466,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||
fn encode_lib_features(&mut self, _: ()) -> LazySeq<(ast::Name, Option<ast::Name>)> {
|
||||
let tcx = self.tcx;
|
||||
let lib_features = tcx.lib_features();
|
||||
self.lazy_seq(lib_features.iter())
|
||||
self.lazy_seq(lib_features.to_vec())
|
||||
}
|
||||
|
||||
fn encode_lang_items(&mut self, _: ()) -> LazySeq<(DefIndex, usize)> {
|
||||
|
|
Loading…
Add table
Reference in a new issue