Skip to content
Permalink
Browse files

Update stability_index, all_crate_nums and features_query

  • Loading branch information...
Zoxc committed Nov 30, 2018
1 parent 9dcc60b commit 10ef70bb68707eda2f0c999a5a06231adcbf967c
Showing with 12 additions and 10 deletions.
  1. +2 −0 src/librustc/arena.rs
  2. +3 −3 src/librustc/query/mod.rs
  3. +6 −6 src/librustc/ty/context.rs
  4. +1 −1 src/librustc_metadata/cstore_impl.rs
@@ -79,6 +79,8 @@ macro_rules! arena_types {
[few] resolve_lifetimes: rustc::middle::resolve_lifetime::ResolveLifetimes,
[decode] generic_predicates: rustc::ty::GenericPredicates<'tcx>,
[few] lint_levels: rustc::lint::LintLevelMap,
[few] stability_index: rustc::middle::stability::Index<'tcx>,
[few] features: syntax::feature_gate::Features,
], $tcx);
)
}
@@ -838,11 +838,11 @@ rustc_queries! {
eval_always
}

query stability_index(_: CrateNum) -> Lrc<stability::Index<'tcx>> {
query stability_index(_: CrateNum) -> &'tcx stability::Index<'tcx> {
eval_always
desc { "calculating the stability index for the local crate" }
}
query all_crate_nums(_: CrateNum) -> Lrc<Vec<CrateNum>> {
query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
eval_always
desc { "fetching all foreign CrateNum instances" }
}
@@ -1062,7 +1062,7 @@ rustc_queries! {
desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
}

query features_query(_: CrateNum) -> Lrc<feature_gate::Features> {
query features_query(_: CrateNum) -> &'tcx feature_gate::Features {
eval_always
desc { "looking up enabled feature gates" }
}
@@ -1420,15 +1420,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
else { None }
}

pub fn stability(self) -> Lrc<stability::Index<'tcx>> {
pub fn stability(self) -> &'gcx stability::Index<'gcx> {
self.stability_index(LOCAL_CRATE)
}

pub fn crates(self) -> Lrc<Vec<CrateNum>> {
pub fn crates(self) -> &'gcx [CrateNum] {
self.all_crate_nums(LOCAL_CRATE)
}

pub fn features(self) -> Lrc<feature_gate::Features> {
pub fn features(self) -> &'gcx feature_gate::Features {
self.features_query(LOCAL_CRATE)
}

@@ -3083,7 +3083,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {

providers.stability_index = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(stability::Index::new(tcx))
tcx.arena.alloc(stability::Index::new(tcx))
};
providers.lookup_stability = |tcx, id| {
assert_eq!(id.krate, LOCAL_CRATE);
@@ -3101,7 +3101,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
};
providers.all_crate_nums = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(tcx.cstore.crates_untracked())
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
};
providers.postorder_cnums = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
@@ -3113,7 +3113,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
};
providers.features_query = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Lrc::new(tcx.sess.features_untracked().clone())
tcx.arena.alloc(tcx.sess.features_untracked().clone())
};
providers.is_panic_runtime = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
@@ -322,7 +322,7 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
// which is to say, its not deterministic in general. But
// we believe that libstd is consistently assigned crate
// num 1, so it should be enough to resolve #46112.
let mut crates: Vec<CrateNum> = (*tcx.crates()).clone();
let mut crates: Vec<CrateNum> = (*tcx.crates()).to_owned();
crates.sort();

for &cnum in crates.iter() {

0 comments on commit 10ef70b

Please sign in to comment.
You can’t perform that action at this time.