diff options
| author | bors <bors@rust-lang.org> | 2023-07-25 05:25:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-25 05:25:11 +0000 |
| commit | 5b1dc9de77106cb08ce9a1a8deaa14f52751d7e4 (patch) | |
| tree | 6d4b1d3d431e7d7682b254c538410546aef50a2d | |
| parent | d24c4da1d6042e23cda5bccc16416fded01bafcf (diff) | |
| parent | 4cc3834a5ced7ed5bc5c63d283c8a5b23fb9ccf6 (diff) | |
| download | rust-5b1dc9de77106cb08ce9a1a8deaa14f52751d7e4.tar.gz rust-5b1dc9de77106cb08ce9a1a8deaa14f52751d7e4.zip | |
Auto merge of #113980 - bvanjoi:fix-113953, r=petrochenkov
fix(resolve): skip panic when resolution is dummy Fixes #113953 Skip the panic when the binding refers to a dummy node during the finalization. r? `@petrochenkov`
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 13 | ||||
| -rw-r--r-- | tests/ui/imports/issue-113953.rs | 6 | ||||
| -rw-r--r-- | tests/ui/imports/issue-113953.stderr | 9 |
3 files changed, 23 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 526fc9c3aa5..f3cf61c5b93 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -989,14 +989,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { initial_binding.res() }); let res = binding.res(); + if res == Res::Err || !this.ambiguity_errors.is_empty() { + this.tcx + .sess + .delay_span_bug(import.span, "some error happened for an import"); + return; + } if let Ok(initial_res) = initial_res { - if res != initial_res && this.ambiguity_errors.is_empty() { + if res != initial_res { span_bug!(import.span, "inconsistent resolution for an import"); } - } else if res != Res::Err - && this.ambiguity_errors.is_empty() - && this.privacy_errors.is_empty() - { + } else if this.privacy_errors.is_empty() { this.tcx .sess .create_err(CannotDetermineImportResolution { span: import.span }) 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`. |
