Auto merge of #56117 - petrochenkov:iempty, r=eddyb

resolve: Make "empty import canaries" invisible from other crates

Empty imports `use prefix::{};` are desugared into `use prefix::{self as _};` to make sure the prefix is checked for privacy/stability/etc.
This caused issues in cross-crate scenarios because gensyms are lost in crate metadata (the `_` is a gensym).

Fixes https://github.com/rust-lang/rust/issues/55811
This commit is contained in:
bors
2018-11-21 12:54:10 +00:00
3 changed files with 15 additions and 1 deletions
+4 -1
View File
@@ -1163,7 +1163,10 @@ fn finalize_resolutions_in(&mut self, module: Module<'b>) {
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() {
@@ -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::{};
+6
View File
@@ -0,0 +1,6 @@
// compile-pass
// aux-build:issue-55811.rs
extern crate issue_55811;
fn main() {}