Rename all_crate_nums query to crates and remove useless wrapper
This commit is contained in:
parent
e98897e5dc
commit
c7d2099de0
21 changed files with 27 additions and 31 deletions
|
@ -277,7 +277,7 @@ fn upstream_monomorphizations_provider(
|
|||
tcx: TyCtxt<'_>,
|
||||
(): (),
|
||||
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
let cnums = tcx.all_crate_nums(());
|
||||
let cnums = tcx.crates(());
|
||||
|
||||
let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
|
||||
|
||||
|
|
|
@ -994,7 +994,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
}
|
||||
Lto::Fat | Lto::Thin => {
|
||||
exported_symbols.insert(LOCAL_CRATE, copy_symbols(LOCAL_CRATE));
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
exported_symbols.insert(cnum, copy_symbols(cnum));
|
||||
}
|
||||
Some(Arc::new(exported_symbols))
|
||||
|
|
|
@ -789,7 +789,7 @@ impl CrateInfo {
|
|||
};
|
||||
let lang_items = tcx.lang_items();
|
||||
|
||||
let crates = tcx.crates();
|
||||
let crates = tcx.crates(());
|
||||
|
||||
let n_crates = crates.len();
|
||||
info.native_libraries.reserve(n_crates);
|
||||
|
|
|
@ -129,7 +129,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||
&& sess.crt_static(Some(ty))
|
||||
&& !sess.target.crt_static_allows_dylibs)
|
||||
{
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
if tcx.dep_kind(cnum).macros_only() {
|
||||
continue;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||
// Sweep all crates for found dylibs. Add all dylibs, as well as their
|
||||
// dependencies, ensuring there are no conflicts. The only valid case for a
|
||||
// dependency to be relied upon twice is for both cases to rely on a dylib.
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
if tcx.dep_kind(cnum).macros_only() {
|
||||
continue;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||
}
|
||||
|
||||
// Collect what we've got so far in the return vector.
|
||||
let last_crate = tcx.crates().len();
|
||||
let last_crate = tcx.crates(()).len();
|
||||
let mut ret = (1..last_crate + 1)
|
||||
.map(|cnum| match formats.get(&CrateNum::new(cnum)) {
|
||||
Some(&RequireDynamic) => Linkage::Dynamic,
|
||||
|
@ -184,7 +184,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
|||
//
|
||||
// If the crate hasn't been included yet and it's not actually required
|
||||
// (e.g., it's an allocator) then we skip it here as well.
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
let src = tcx.used_crate_source(cnum);
|
||||
if src.dylib.is_none()
|
||||
&& !formats.contains_key(&cnum)
|
||||
|
@ -281,7 +281,7 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
|
|||
|
||||
// All crates are available in an rlib format, so we're just going to link
|
||||
// everything in explicitly so long as it's actually required.
|
||||
let last_crate = tcx.crates().len();
|
||||
let last_crate = tcx.crates(()).len();
|
||||
let mut ret = (1..last_crate + 1)
|
||||
.map(|cnum| {
|
||||
if tcx.dep_kind(CrateNum::new(cnum)) == CrateDepKind::Explicit {
|
||||
|
|
|
@ -312,7 +312,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
// 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()).to_owned();
|
||||
let mut crates: Vec<CrateNum> = (*tcx.crates(())).to_owned();
|
||||
crates.sort();
|
||||
|
||||
for &cnum in crates.iter() {
|
||||
|
|
|
@ -1668,7 +1668,7 @@ impl EncodeContext<'a, 'tcx> {
|
|||
|
||||
fn encode_crate_deps(&mut self) -> Lazy<[CrateDep]> {
|
||||
empty_proc_macro!(self);
|
||||
let crates = self.tcx.crates();
|
||||
let crates = self.tcx.crates(());
|
||||
|
||||
let mut deps = crates
|
||||
.iter()
|
||||
|
|
|
@ -229,7 +229,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
|
|||
// positions.
|
||||
pub fn used_crates(tcx: TyCtxt<'_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> {
|
||||
let mut libs = tcx
|
||||
.crates()
|
||||
.crates(())
|
||||
.iter()
|
||||
.cloned()
|
||||
.filter_map(|cnum| {
|
||||
|
|
|
@ -1444,7 +1444,7 @@ rustc_queries! {
|
|||
eval_always
|
||||
desc { "calculating the stability index for the local crate" }
|
||||
}
|
||||
query all_crate_nums(_: ()) -> &'tcx [CrateNum] {
|
||||
query crates(_: ()) -> &'tcx [CrateNum] {
|
||||
eval_always
|
||||
desc { "fetching all foreign CrateNum instances" }
|
||||
}
|
||||
|
|
|
@ -1259,10 +1259,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.stability_index(())
|
||||
}
|
||||
|
||||
pub fn crates(self) -> &'tcx [CrateNum] {
|
||||
self.all_crate_nums(())
|
||||
}
|
||||
|
||||
pub fn features(self) -> &'tcx rustc_feature::Features {
|
||||
self.features_query(())
|
||||
}
|
||||
|
@ -2819,7 +2815,7 @@ 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, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
|
||||
providers.crates = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
|
||||
providers.output_filenames = |tcx, ()| tcx.output_filenames.clone();
|
||||
providers.features_query = |tcx, ()| tcx.sess.features_untracked();
|
||||
providers.is_panic_runtime = |tcx, cnum| {
|
||||
|
|
|
@ -2248,7 +2248,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
|||
let queue = &mut Vec::new();
|
||||
let mut seen_defs: DefIdSet = Default::default();
|
||||
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
|
||||
|
||||
// Ignore crates that are not direct dependencies.
|
||||
|
|
|
@ -558,7 +558,7 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
// maps to None.
|
||||
fn compute_cnum_map(tcx: TyCtxt<'_>) -> UnhashMap<StableCrateId, CrateNum> {
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
tcx.all_crate_nums(())
|
||||
tcx.crates(())
|
||||
.iter()
|
||||
.chain(std::iter::once(&LOCAL_CRATE))
|
||||
.map(|&cnum| {
|
||||
|
|
|
@ -215,7 +215,7 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> Trait
|
|||
// Traits defined in the current crate can't have impls in upstream
|
||||
// crates, so we don't bother querying the cstore.
|
||||
if !trait_id.is_local() {
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
for &(impl_def_id, simplified_self_ty) in
|
||||
tcx.implementations_of_trait((cnum, trait_id)).iter()
|
||||
{
|
||||
|
|
|
@ -121,7 +121,7 @@ fn all_diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> FxHashMap<Symbol, De
|
|||
let mut collector = FxHashMap::default();
|
||||
|
||||
// Collect diagnostic items in other crates.
|
||||
for &cnum in tcx.crates().iter().chain(std::iter::once(&LOCAL_CRATE)) {
|
||||
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
|
||||
for (&name, &def_id) in tcx.diagnostic_items(cnum).iter() {
|
||||
collect_item(tcx, &mut collector, name, def_id);
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
|
|||
let mut collector = LanguageItemCollector::new(tcx);
|
||||
|
||||
// Collect lang items in other crates.
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
for &(def_id, item_index) in tcx.defined_lang_items(cnum).iter() {
|
||||
collector.collect_item(item_index, def_id);
|
||||
}
|
||||
|
|
|
@ -938,7 +938,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
|||
if !remaining_lib_features.is_empty() {
|
||||
check_features(&mut remaining_lib_features, &local_defined_features);
|
||||
|
||||
for &cnum in tcx.crates() {
|
||||
for &cnum in tcx.crates(()) {
|
||||
if remaining_lib_features.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
|
|||
}
|
||||
|
||||
let mut missing = FxHashSet::default();
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
for &item in tcx.missing_lang_items(cnum).iter() {
|
||||
missing.insert(item);
|
||||
}
|
||||
|
|
|
@ -109,9 +109,9 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
|
||||
// List external crates used by the current crate.
|
||||
pub fn get_external_crates(&self) -> Vec<ExternalCrateData> {
|
||||
let mut result = Vec::with_capacity(self.tcx.crates().len());
|
||||
let mut result = Vec::with_capacity(self.tcx.crates(()).len());
|
||||
|
||||
for &n in self.tcx.crates().iter() {
|
||||
for &n in self.tcx.crates(()).iter() {
|
||||
let span = match self.tcx.extern_crate(n.as_def_id()) {
|
||||
Some(&ExternCrate { span, .. }) => span,
|
||||
None => {
|
||||
|
|
|
@ -1591,7 +1591,7 @@ fn compute_all_traits(tcx: TyCtxt<'_>, (): ()) -> &[DefId] {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
for &cnum in tcx.crates().iter() {
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
|
||||
handle_external_res(tcx, &mut traits, &mut external_mods, Res::Def(DefKind::Mod, def_id));
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
|
|||
cx.cache.owned_box_did = cx.tcx.lang_items().owned_box();
|
||||
|
||||
let mut externs = Vec::new();
|
||||
for &cnum in cx.tcx.crates().iter() {
|
||||
for &cnum in cx.tcx.crates(()).iter() {
|
||||
externs.push((cnum, cnum.clean(cx)));
|
||||
// Analyze doc-reachability for extern items
|
||||
LibEmbargoVisitor::new(cx).visit_lib(cnum);
|
||||
|
|
|
@ -29,7 +29,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
|||
|
||||
let mut new_items = Vec::new();
|
||||
|
||||
for &cnum in cx.tcx.crates().iter() {
|
||||
for &cnum in cx.tcx.crates(()).iter() {
|
||||
for &(did, _) in cx.tcx.all_trait_implementations(cnum).iter() {
|
||||
cx.tcx.sess.prof.generic_activity("build_extern_trait_impl").run(|| {
|
||||
inline::build_impl(cx, None, did, None, &mut new_items);
|
||||
|
@ -85,7 +85,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
|
|||
}
|
||||
});
|
||||
|
||||
// `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations`
|
||||
// `tcx.crates(())` doesn't include the local crate, and `tcx.all_trait_implementations`
|
||||
// doesn't work with it anyway, so pull them from the HIR map instead
|
||||
let mut extra_attrs = Vec::new();
|
||||
for &trait_did in cx.tcx.all_traits(()).iter() {
|
||||
|
|
|
@ -493,7 +493,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
|
|||
_ => return Res::Err,
|
||||
};
|
||||
let tcx = cx.tcx;
|
||||
let crates = tcx.crates();
|
||||
let crates = tcx.crates(());
|
||||
let krate = try_res!(crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate));
|
||||
let first = try_res!(item_child_by_name(tcx, krate.as_def_id(), first));
|
||||
let last = path
|
||||
|
|
Loading…
Add table
Reference in a new issue