Use cnum for extern crate data
This commit is contained in:
parent
c6f81a452e
commit
b2dd943d4b
5 changed files with 8 additions and 10 deletions
|
@ -1520,7 +1520,7 @@ rustc_queries! {
|
|||
separate_provide_extern
|
||||
}
|
||||
|
||||
query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
|
||||
query extern_crate(def_id: CrateNum) -> Option<&'tcx ExternCrate> {
|
||||
eval_always
|
||||
desc { "getting crate's ExternCrateData" }
|
||||
separate_provide_extern
|
||||
|
|
|
@ -451,7 +451,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
// 2. For an extern inferred from a path or an indirect crate,
|
||||
// where there is no explicit `extern crate`, we just prepend
|
||||
// the crate name.
|
||||
match self.tcx().extern_crate(def_id) {
|
||||
match self.tcx().extern_crate(cnum) {
|
||||
Some(&ExternCrate { src, dependency_of, span, .. }) => match (src, dependency_of) {
|
||||
(ExternCrateSource::Extern(def_id), LOCAL_CRATE) => {
|
||||
// NOTE(eddyb) the only reason `span` might be dummy,
|
||||
|
@ -3247,10 +3247,8 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
|||
let mut seen_defs: DefIdSet = Default::default();
|
||||
|
||||
for &cnum in tcx.crates(()).iter() {
|
||||
let def_id = cnum.as_def_id();
|
||||
|
||||
// Ignore crates that are not direct dependencies.
|
||||
match tcx.extern_crate(def_id) {
|
||||
match tcx.extern_crate(cnum) {
|
||||
None => continue,
|
||||
Some(extern_crate) => {
|
||||
if !extern_crate.is_direct() {
|
||||
|
@ -3259,7 +3257,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
|||
}
|
||||
}
|
||||
|
||||
queue.push(def_id);
|
||||
queue.push(cnum.as_def_id());
|
||||
}
|
||||
|
||||
// Iterate external crate defs but be mindful about visibility
|
||||
|
|
|
@ -859,7 +859,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// If `extern_crate` is `None`, then the crate was injected (e.g., by the allocator).
|
||||
// Treat that kind of crate as "indirect", since it's an implementation detail of
|
||||
// the language.
|
||||
|| self.extern_crate(key.as_def_id()).is_some_and(|e| e.is_direct())
|
||||
|| self.extern_crate(key).is_some_and(|e| e.is_direct())
|
||||
}
|
||||
|
||||
/// Whether the item has a host effect param. This is different from `TyCtxt::is_const`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue