Use () for lang items.
This commit is contained in:
parent
9849327384
commit
437a46ddfa
8 changed files with 30 additions and 53 deletions
|
@ -279,7 +279,7 @@ fn upstream_monomorphizations_provider(
|
|||
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
debug_assert!(cnum == LOCAL_CRATE);
|
||||
|
||||
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
|
||||
let cnums = tcx.all_crate_nums(());
|
||||
|
||||
let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
|
||||
|
||||
|
|
|
@ -1330,7 +1330,7 @@ rustc_queries! {
|
|||
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query get_lib_features(_: CrateNum) -> LibFeatures {
|
||||
query get_lib_features(_: ()) -> LibFeatures {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lib features map" }
|
||||
|
@ -1340,16 +1340,14 @@ rustc_queries! {
|
|||
desc { "calculating the lib features defined in a crate" }
|
||||
}
|
||||
/// Returns the lang items defined in another crate by loading it from metadata.
|
||||
// FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
|
||||
// of that argument?
|
||||
query get_lang_items(_: CrateNum) -> LanguageItems {
|
||||
query get_lang_items(_: ()) -> LanguageItems {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lang items map" }
|
||||
}
|
||||
|
||||
/// Returns all diagnostic items defined in all crates.
|
||||
query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
query all_diagnostic_items(_: ()) -> FxHashMap<Symbol, DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the diagnostic items map" }
|
||||
|
@ -1411,12 +1409,12 @@ rustc_queries! {
|
|||
desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query stability_index(_: CrateNum) -> stability::Index<'tcx> {
|
||||
query stability_index(_: ()) -> stability::Index<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the stability index for the local crate" }
|
||||
}
|
||||
query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
|
||||
query all_crate_nums(_: ()) -> &'tcx [CrateNum] {
|
||||
eval_always
|
||||
desc { "fetching all foreign CrateNum instances" }
|
||||
}
|
||||
|
@ -1644,7 +1642,7 @@ rustc_queries! {
|
|||
desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
|
||||
}
|
||||
|
||||
query features_query(_: CrateNum) -> &'tcx rustc_feature::Features {
|
||||
query features_query(_: ()) -> &'tcx rustc_feature::Features {
|
||||
eval_always
|
||||
desc { "looking up enabled feature gates" }
|
||||
}
|
||||
|
|
|
@ -1218,18 +1218,18 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures {
|
||||
self.get_lib_features(LOCAL_CRATE)
|
||||
self.get_lib_features(())
|
||||
}
|
||||
|
||||
/// Obtain all lang items of this crate and all dependencies (recursively)
|
||||
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
|
||||
self.get_lang_items(LOCAL_CRATE)
|
||||
self.get_lang_items(())
|
||||
}
|
||||
|
||||
/// Obtain the given diagnostic item's `DefId`. Use `is_diagnostic_item` if you just want to
|
||||
/// compare against another `DefId`, since `is_diagnostic_item` is cheaper.
|
||||
pub fn get_diagnostic_item(self, name: Symbol) -> Option<DefId> {
|
||||
self.all_diagnostic_items(LOCAL_CRATE).get(&name).copied()
|
||||
self.all_diagnostic_items(()).get(&name).copied()
|
||||
}
|
||||
|
||||
/// Check whether the diagnostic item with the given `name` has the given `DefId`.
|
||||
|
@ -1238,11 +1238,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn stability(self) -> &'tcx stability::Index<'tcx> {
|
||||
self.stability_index(LOCAL_CRATE)
|
||||
self.stability_index(())
|
||||
}
|
||||
|
||||
pub fn crates(self) -> &'tcx [CrateNum] {
|
||||
self.all_crate_nums(LOCAL_CRATE)
|
||||
self.all_crate_nums(())
|
||||
}
|
||||
|
||||
pub fn allocator_kind(self) -> Option<AllocatorKind> {
|
||||
|
@ -1250,7 +1250,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn features(self) -> &'tcx rustc_feature::Features {
|
||||
self.features_query(LOCAL_CRATE)
|
||||
self.features_query(())
|
||||
}
|
||||
|
||||
pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
|
||||
|
@ -2815,18 +2815,12 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
|||
tcx.stability().local_deprecation_entry(id)
|
||||
};
|
||||
providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned();
|
||||
providers.all_crate_nums = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.arena.alloc_slice(&tcx.cstore.crates_untracked())
|
||||
};
|
||||
providers.all_crate_nums = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
|
||||
providers.output_filenames = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.output_filenames.clone()
|
||||
};
|
||||
providers.features_query = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.features_untracked()
|
||||
};
|
||||
providers.features_query = |tcx, ()| tcx.sess.features_untracked();
|
||||
providers.is_panic_runtime = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.sess.contains_name(tcx.hir().krate_attrs(), sym::panic_runtime)
|
||||
|
|
|
@ -579,7 +579,7 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
) -> IndexVec<CrateNum, Option<CrateNum>> {
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
let current_cnums = tcx
|
||||
.all_crate_nums(LOCAL_CRATE)
|
||||
.all_crate_nums(())
|
||||
.iter()
|
||||
.map(|&cnum| {
|
||||
let crate_name = tcx.original_crate_name(cnum).to_string();
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
|||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::def_id::{DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_span::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
struct DiagnosticItemCollector<'tcx> {
|
||||
|
@ -99,7 +99,9 @@ fn extract(sess: &Session, attrs: &[ast::Attribute]) -> Option<Symbol> {
|
|||
}
|
||||
|
||||
/// Traverse and collect the diagnostic items in the current
|
||||
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
// Initialize the collector.
|
||||
let mut collector = DiagnosticItemCollector::new(tcx);
|
||||
|
||||
|
@ -114,7 +116,7 @@ fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
|||
}
|
||||
|
||||
/// Traverse and collect all the diagnostic items in all crates.
|
||||
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
fn all_diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashMap<Symbol, DefId> {
|
||||
// Initialize the collector.
|
||||
let mut collector = FxHashMap::default();
|
||||
|
||||
|
@ -129,12 +131,6 @@ fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
|||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.diagnostic_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect(tcx)
|
||||
};
|
||||
providers.all_diagnostic_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect_all(tcx)
|
||||
};
|
||||
providers.diagnostic_items = diagnostic_items;
|
||||
providers.all_diagnostic_items = all_diagnostic_items;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_middle::ty::TyCtxt;
|
|||
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::lang_items::{extract, ITEM_REFS};
|
||||
use rustc_hir::{HirId, LangItem, LanguageItems, Target};
|
||||
|
@ -183,7 +183,7 @@ impl LanguageItemCollector<'tcx> {
|
|||
}
|
||||
|
||||
/// Traverses and collects all the lang items in all crates.
|
||||
fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
|
||||
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
|
||||
// Initialize the collector.
|
||||
let mut collector = LanguageItemCollector::new(tcx);
|
||||
|
||||
|
@ -207,8 +207,5 @@ fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
|
|||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.get_lang_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect(tcx)
|
||||
};
|
||||
providers.get_lang_items = get_lang_items;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
use rustc_ast::{Attribute, MetaItem, MetaItemKind};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::middle::lib_features::LibFeatures;
|
||||
|
@ -127,7 +126,7 @@ impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
|
||||
fn get_lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures {
|
||||
let mut collector = LibFeatureCollector::new(tcx);
|
||||
let krate = tcx.hir().krate();
|
||||
for attr in krate.non_exported_macro_attrs {
|
||||
|
@ -138,8 +137,5 @@ fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
|
|||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.get_lib_features = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
collect(tcx)
|
||||
};
|
||||
providers.get_lib_features = get_lib_features;
|
||||
}
|
||||
|
|
|
@ -629,7 +629,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
|||
// stable (assuming they have not inherited instability from their parent).
|
||||
}
|
||||
|
||||
fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
|
||||
fn stability_index(tcx: TyCtxt<'tcx>, (): ()) -> Index<'tcx> {
|
||||
let is_staged_api =
|
||||
tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api;
|
||||
let mut staged_api = FxHashMap::default();
|
||||
|
@ -704,11 +704,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
|
|||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { check_mod_unstable_api_usage, ..*providers };
|
||||
providers.stability_index = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
new_index(tcx)
|
||||
};
|
||||
*providers = Providers { check_mod_unstable_api_usage, stability_index, ..*providers };
|
||||
}
|
||||
|
||||
struct Checker<'tcx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue