Skip to content

Commit e543e31

Browse files
committed
resolve: Avoid "self-confirming" import resolutions in one more case
1 parent 7900b2b commit e543e31

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/librustc_resolve/imports.rs

+9
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
874874
/// consolidate multiple unresolved import errors into a single diagnostic.
875875
fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImportError> {
876876
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
877+
let orig_blacklisted_binding = match &import.kind {
878+
ImportKind::Single { target_bindings, .. } => {
879+
Some(mem::replace(&mut self.r.blacklisted_binding, target_bindings[TypeNS].get()))
880+
}
881+
_ => None,
882+
};
877883
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
878884
let path_res = self.r.resolve_path(
879885
&import.module_path,
@@ -884,6 +890,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
884890
import.crate_lint(),
885891
);
886892
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
893+
if let Some(orig_blacklisted_binding) = orig_blacklisted_binding {
894+
self.r.blacklisted_binding = orig_blacklisted_binding;
895+
}
887896
import.vis.set(orig_vis);
888897
if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
889898
// Consider erroneous imports used to avoid duplicate diagnostics.

src/test/ui/imports/issue-62767.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
mod m {
4+
pub enum Same {
5+
Same,
6+
}
7+
}
8+
9+
use m::*;
10+
11+
// The variant `Same` introduced by this import is not considered when resolving the prefix
12+
// `Same::` during import validation (issue #62767).
13+
use Same::Same;
14+
15+
fn main() {}

0 commit comments

Comments
 (0)