Skip to content

fix(resolve): skip panic when resolution is dummy #113980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/imports/issue-113953.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// edition: 2021
use u8 as imported_u8;
use unresolved as u8;
//~^ ERROR unresolved import `unresolved`

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/imports/issue-113953.stderr
Original file line number Diff line number Diff line change
@@ -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`.