From 1e4cf740cfaf5332722ae6ff717ceaed181a4caf Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 21 Nov 2018 03:39:41 +0300 Subject: [PATCH] resolve: Make "empty import canaries" invisible from other crates --- src/librustc_resolve/resolve_imports.rs | 5 ++++- src/test/ui/imports/auxiliary/issue-55811.rs | 5 +++++ src/test/ui/imports/issue-55811.rs | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/imports/auxiliary/issue-55811.rs create mode 100644 src/test/ui/imports/issue-55811.rs diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 9e5036b6e50..c2ba3048c1b 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1164,7 +1164,10 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { None => continue, }; - if binding.is_import() || binding.is_macro_def() { + // Filter away "empty import canaries". + let is_non_canary_import = + binding.is_import() && binding.vis != ty::Visibility::Invisible; + if is_non_canary_import || binding.is_macro_def() { let def = binding.def(); if def != Def::Err { if let Some(def_id) = def.opt_def_id() { diff --git a/src/test/ui/imports/auxiliary/issue-55811.rs b/src/test/ui/imports/auxiliary/issue-55811.rs new file mode 100644 index 00000000000..877e4cdb0bd --- /dev/null +++ b/src/test/ui/imports/auxiliary/issue-55811.rs @@ -0,0 +1,5 @@ +mod m {} + +// These two imports should not conflict when this crate is loaded from some other crate. +use m::{}; +use m::{}; diff --git a/src/test/ui/imports/issue-55811.rs b/src/test/ui/imports/issue-55811.rs new file mode 100644 index 00000000000..95316777fab --- /dev/null +++ b/src/test/ui/imports/issue-55811.rs @@ -0,0 +1,6 @@ +// compile-pass +// aux-build:issue-55811.rs + +extern crate issue_55811; + +fn main() {}