diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-27 18:48:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-27 18:48:51 +0100 |
| commit | a184150247298c98edd445d241ef487e197c91a9 (patch) | |
| tree | 0ef12dd8679cca8e65e6b9bb14bd578f4e145058 | |
| parent | 828b66e6de8c8b0aaf33bf971d36bd6de75cd7ca (diff) | |
| parent | f058bb0fcfeef3ebb0da19b2399f575c3aa9c3e8 (diff) | |
| download | rust-a184150247298c98edd445d241ef487e197c91a9.tar.gz rust-a184150247298c98edd445d241ef487e197c91a9.zip | |
Rollup merge of #108533 - notriddle:notriddle/resolver-def-descr, r=compiler-errors
diagnostics: avoid querying `associated_item` in the resolver Fixes #108529 CC #108324
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 8 | ||||
| -rw-r--r-- | tests/ui/resolve/issue-108529.rs | 8 | ||||
| -rw-r--r-- | tests/ui/resolve/issue-108529.stderr | 9 |
3 files changed, 23 insertions, 2 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index ee2d2301399..7add59ac627 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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", }; @@ -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()), } } diff --git a/tests/ui/resolve/issue-108529.rs b/tests/ui/resolve/issue-108529.rs new file mode 100644 index 00000000000..8e3aafab6aa --- /dev/null +++ b/tests/ui/resolve/issue-108529.rs @@ -0,0 +1,8 @@ +#![allow(nonstandard_style)] +use f::f::f; //~ ERROR + +trait f { + extern "C" fn f(); +} + +fn main() {} diff --git a/tests/ui/resolve/issue-108529.stderr b/tests/ui/resolve/issue-108529.stderr new file mode 100644 index 00000000000..cf4e4759c37 --- /dev/null +++ b/tests/ui/resolve/issue-108529.stderr @@ -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`. |
