Skip to content

Commit 5b1dc9d

Browse files
committed
Auto merge of rust-lang#113980 - bvanjoi:fix-113953, r=petrochenkov
fix(resolve): skip panic when resolution is dummy Fixes rust-lang#113953 Skip the panic when the binding refers to a dummy node during the finalization. r? `@petrochenkov`
2 parents d24c4da + 4cc3834 commit 5b1dc9d

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

compiler/rustc_resolve/src/imports.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
989989
initial_binding.res()
990990
});
991991
let res = binding.res();
992+
if res == Res::Err || !this.ambiguity_errors.is_empty() {
993+
this.tcx
994+
.sess
995+
.delay_span_bug(import.span, "some error happened for an import");
996+
return;
997+
}
992998
if let Ok(initial_res) = initial_res {
993-
if res != initial_res && this.ambiguity_errors.is_empty() {
999+
if res != initial_res {
9941000
span_bug!(import.span, "inconsistent resolution for an import");
9951001
}
996-
} else if res != Res::Err
997-
&& this.ambiguity_errors.is_empty()
998-
&& this.privacy_errors.is_empty()
999-
{
1002+
} else if this.privacy_errors.is_empty() {
10001003
this.tcx
10011004
.sess
10021005
.create_err(CannotDetermineImportResolution { span: import.span })

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)