Skip to content

Commit

Permalink
Auto merge of #103096 - petrochenkov:indresdoc, r=cjgillot
Browse files Browse the repository at this point in the history
resolve: Shadow erroneous glob imports with erroneous single imports

If such shadowing doesn't happen we end up in a weird state that may cause ICEs.
(In non-erroneous cases single imports always shadow glob imports too.)

Fixes #100047
Fixes #100241
  • Loading branch information
bors committed Oct 17, 2022
2 parents a501e66 + f767f22 commit 1536ab1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl<'a> Resolver<'a> {
self.set_binding_parent_module(binding, module);
self.update_resolution(module, key, |this, resolution| {
if let Some(old_binding) = resolution.binding {
if res == Res::Err {
if res == Res::Err && old_binding.res() != Res::Err {
// Do not override real bindings with `Res::Err`s from error recovery.
return Ok(());
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc/issue-100241.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! See [`S`].

// Check that this isn't an ICE
// should-fail

mod foo {
pub use inner::S;
//~^ ERROR unresolved imports `inner`, `foo::S`
}

use foo::*;
use foo::S;

0 comments on commit 1536ab1

Please sign in to comment.