Skip to content

Commit bd90137

Browse files
committed
Improve query efficiency
1 parent e5d5e6a commit bd90137

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ define_dep_nodes!( <'tcx>
615615
[input] CrateName(CrateNum),
616616
[] ItemChildren(DefId),
617617
[] ExternModStmtCnum(DefId),
618-
[input] GetLibFeatures,
618+
[eval_always] GetLibFeatures,
619619
[] DefinedLibFeatures(CrateNum),
620620
[eval_always] GetLangItems,
621621
[] DefinedLangItems(CrateNum),

src/librustc/middle/lib_features.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ impl LibFeatures {
3737
}
3838
}
3939

40-
pub fn iter(&self) -> Vec<(Symbol, Option<Symbol>)> {
41-
self.stable.iter().map(|(f, s)| (*f, Some(*s)))
40+
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
41+
let mut all_features: Vec<_> = self.stable.iter().map(|(f, s)| (*f, Some(*s)))
4242
.chain(self.unstable.iter().map(|f| (*f, None)))
43-
.collect()
43+
.collect();
44+
all_features.sort_unstable_by_key(|f| f.0.as_str());
45+
all_features
4446
}
4547
}
4648

src/librustc/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
841841
// FIXME: only remove `libc` when `stdbuild` is active.
842842
remaining_lib_features.remove(&Symbol::intern("libc"));
843843

844-
for (feature, stable) in tcx.lib_features().iter() {
844+
for (feature, stable) in tcx.lib_features().to_vec() {
845845
if let Some(since) = stable {
846846
if let Some(span) = remaining_lib_features.get(&feature) {
847847
// Warn if the user has enabled an already-stable lib feature.

src/librustc/ty/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,8 +2846,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
28462846
};
28472847
providers.get_lib_features = |tcx, id| {
28482848
assert_eq!(id, LOCAL_CRATE);
2849-
// FIXME(#42293): see comment below.
2850-
tcx.dep_graph.with_ignore(|| Lrc::new(middle::lib_features::collect(tcx)))
2849+
Lrc::new(middle::lib_features::collect(tcx))
28512850
};
28522851
providers.get_lang_items = |tcx, id| {
28532852
assert_eq!(id, LOCAL_CRATE);

src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,10 @@ impl<'a, 'tcx> CrateMetadata {
647647

648648
/// Iterates over all the stability attributes in the given crate.
649649
pub fn get_lib_features(&self) -> Vec<(ast::Name, Option<ast::Name>)> {
650-
let mut features: Vec<_> = self.root
650+
self.root
651651
.lib_features
652652
.decode(self)
653-
.collect();
654-
features.sort_unstable_by_key(|f| f.0.as_str());
655-
features
653+
.collect()
656654
}
657655

658656
/// Iterates over the language items in the given crate.

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
14661466
fn encode_lib_features(&mut self, _: ()) -> LazySeq<(ast::Name, Option<ast::Name>)> {
14671467
let tcx = self.tcx;
14681468
let lib_features = tcx.lib_features();
1469-
self.lazy_seq(lib_features.iter())
1469+
self.lazy_seq(lib_features.to_vec())
14701470
}
14711471

14721472
fn encode_lang_items(&mut self, _: ()) -> LazySeq<(DefIndex, usize)> {

0 commit comments

Comments
 (0)