diff options
| author | bohan <bohan-zhang@foxmail.com> | 2023-07-23 20:21:53 +0800 |
|---|---|---|
| committer | bohan <bohan-zhang@foxmail.com> | 2023-07-25 01:34:03 +0800 |
| commit | 02f1f6a8a893bbaabc87079a61815685b0f88d75 (patch) | |
| tree | acc7c3a6b2abb784355b7224f784ec0b93cf6b0f | |
| parent | cb6ab9516bbbd3859b56dd23e32fe41600e0ae02 (diff) | |
fix(resolve): skip panic when resolution is dummy
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 5 | ||||
| -rw-r--r-- | tests/ui/imports/issue-113953.rs | 6 | ||||
| -rw-r--r-- | tests/ui/imports/issue-113953.stderr | 9 |
3 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 526fc9c3aa5..f18aedd190f 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -990,7 +990,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }); let res = binding.res(); if let Ok(initial_res) = initial_res { - if res != initial_res && this.ambiguity_errors.is_empty() { + if res != initial_res + && this.ambiguity_errors.is_empty() + && res != Res::Err + { span_bug!(import.span, "inconsistent resolution for an import"); } } else if res != Res::Err diff --git a/tests/ui/imports/issue-113953.rs b/tests/ui/imports/issue-113953.rs new file mode 100644 index 00000000000..449a074f4b5 --- /dev/null +++ b/tests/ui/imports/issue-113953.rs @@ -0,0 +1,6 @@ +// edition: 2021 +use u8 as imported_u8; +use unresolved as u8; +//~^ ERROR unresolved import `unresolved` + +fn main() {} diff --git a/tests/ui/imports/issue-113953.stderr b/tests/ui/imports/issue-113953.stderr new file mode 100644 index 00000000000..70f91bd3c5b --- /dev/null +++ b/tests/ui/imports/issue-113953.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/issue-113953.rs:3:5 + | +LL | use unresolved as u8; + | ^^^^^^^^^^^^^^^^ no external crate `unresolved` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. |
