Skip to content
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

resolve: Avoid "self-confirming" import resolutions in one more case #70236

Merged
merged 1 commit into from
Mar 23, 2020
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
9 changes: 9 additions & 0 deletions src/librustc_resolve/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// consolidate multiple unresolved import errors into a single diagnostic.
fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImportError> {
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
let orig_blacklisted_binding = match &import.kind {
ImportKind::Single { target_bindings, .. } => {
Some(mem::replace(&mut self.r.blacklisted_binding, target_bindings[TypeNS].get()))
}
_ => None,
};
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
let path_res = self.r.resolve_path(
&import.module_path,
Expand All @@ -884,6 +890,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
import.crate_lint(),
);
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
if let Some(orig_blacklisted_binding) = orig_blacklisted_binding {
self.r.blacklisted_binding = orig_blacklisted_binding;
}
import.vis.set(orig_vis);
if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
// Consider erroneous imports used to avoid duplicate diagnostics.
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/imports/issue-62767.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass

mod m {
pub enum Same {
Same,
}
}

use m::*;

// The variant `Same` introduced by this import is not considered when resolving the prefix
// `Same::` during import validation (issue #62767).
use Same::Same;

fn main() {}