Skip to content

Commit 02f1f6a

Browse files
committed
fix(resolve): skip panic when resolution is dummy
1 parent cb6ab95 commit 02f1f6a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

compiler/rustc_resolve/src/imports.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
990990
});
991991
let res = binding.res();
992992
if let Ok(initial_res) = initial_res {
993-
if res != initial_res && this.ambiguity_errors.is_empty() {
993+
if res != initial_res
994+
&& this.ambiguity_errors.is_empty()
995+
&& res != Res::Err
996+
{
994997
span_bug!(import.span, "inconsistent resolution for an import");
995998
}
996999
} else if res != Res::Err

tests/ui/imports/issue-113953.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// edition: 2021
2+
use u8 as imported_u8;
3+
use unresolved as u8;
4+
//~^ ERROR unresolved import `unresolved`
5+
6+
fn main() {}

tests/ui/imports/issue-113953.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0432]: unresolved import `unresolved`
2+
--> $DIR/issue-113953.rs:3:5
3+
|
4+
LL | use unresolved as u8;
5+
| ^^^^^^^^^^^^^^^^ no external crate `unresolved`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)