Skip to content

diagnostics: avoid querying associated_item in the resolver #108533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

let container = match parent.kind {
ModuleKind::Def(kind, _, _) => self.tcx.def_kind_descr(kind, parent.def_id()),
// Avoid using TyCtxt::def_kind_descr in the resolver, because it
// indirectly *calls* the resolver, and would cause a query cycle.
ModuleKind::Def(kind, _, _) => kind.descr(parent.def_id()),
ModuleKind::Block => "block",
};

Expand Down Expand Up @@ -1804,7 +1806,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
found("module")
} else {
match binding.res() {
Res::Def(kind, id) => found(self.tcx.def_kind_descr(kind, id)),
// Avoid using TyCtxt::def_kind_descr in the resolver, because it
// indirectly *calls* the resolver, and would cause a query cycle.
Res::Def(kind, id) => found(kind.descr(id)),
_ => found(ns_to_try.descr()),
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/resolve/issue-108529.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![allow(nonstandard_style)]
use f::f::f; //~ ERROR

trait f {
extern "C" fn f();
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/resolve/issue-108529.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0432]: unresolved import `f::f`
--> $DIR/issue-108529.rs:2:8
|
LL | use f::f::f;
| ^ expected type, found associated function `f` in `f`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.