Rollup merge of #129203 - compiler-errors:extern_crate_data, r=jieyouxu
Use cnum for extern crate data key Noticed this when fixing #129184. I still have yet to put up a fix for that (mostly because I'm too lazy to minimize a test, that will come soon though).
This commit is contained in:
commit
130cb9e30c
@ -1520,7 +1520,7 @@
|
||||
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 @@ fn try_print_visible_def_path_recur(
|
||||
// 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 @@ pub fn is_user_visible_dep(self, key: CrateNum) -> bool {
|
||||
// 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`,
|
||||
|
@ -130,7 +130,7 @@ fn collect_item(&mut self, lang_item: LangItem, item_def_id: DefId, item_span: O
|
||||
if first_defined_span.is_none() {
|
||||
orig_crate_name = self.tcx.crate_name(original_def_id.krate);
|
||||
if let Some(ExternCrate { dependency_of: inner_dependency_of, .. }) =
|
||||
self.tcx.extern_crate(original_def_id)
|
||||
self.tcx.extern_crate(original_def_id.krate)
|
||||
{
|
||||
orig_dependency_of = self.tcx.crate_name(*inner_dependency_of);
|
||||
}
|
||||
@ -139,7 +139,7 @@ fn collect_item(&mut self, lang_item: LangItem, item_def_id: DefId, item_span: O
|
||||
let duplicate = if item_span.is_some() {
|
||||
Duplicate::Plain
|
||||
} else {
|
||||
match self.tcx.extern_crate(item_def_id) {
|
||||
match self.tcx.extern_crate(item_def_id.krate) {
|
||||
Some(ExternCrate { dependency_of: inner_dependency_of, .. }) => {
|
||||
dependency_of = self.tcx.crate_name(*inner_dependency_of);
|
||||
Duplicate::CrateDepends
|
||||
|
@ -1668,7 +1668,7 @@ pub(super) fn report_similar_impl_candidates(
|
||||
let name = self.tcx.crate_name(trait_def_id.krate);
|
||||
let spans: Vec<_> = [trait_def_id, found_type]
|
||||
.into_iter()
|
||||
.filter_map(|def_id| self.tcx.extern_crate(def_id))
|
||||
.filter_map(|def_id| self.tcx.extern_crate(def_id.krate))
|
||||
.map(|data| {
|
||||
let dependency = if data.dependency_of == LOCAL_CRATE {
|
||||
"direct dependency of the current crate".to_string()
|
||||
|
Loading…
Reference in New Issue
Block a user