]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #32814 - jseyfried:improve_duplicate_glob_detection, r=nikomatsakis
authorbors <bors@rust-lang.org>
Wed, 13 Apr 2016 05:21:23 +0000 (22:21 -0700)
committerbors <bors@rust-lang.org>
Wed, 13 Apr 2016 05:21:23 +0000 (22:21 -0700)
resolve: Improve duplicate glob detection

This fixes a bug introduced in #31726 in which we erroneously allow multiple imports of the same item under some circumstances.

More specifically, we erroneously allow a module that is in a cycle of glob re-exports to have other re-exports (besides the glob from the cycle).
For example,
```rust
pub fn f() {}
mod foo {
    pub use f; // (1) This defines `foo::f`.
    pub use bar::*; // (3) This also defines `foo::f`, which should be a duplicate error but is currently allowed.
}
mod bar {
    pub use foo::*; // (2) This defines `bar::f`.
}
```

A module in a glob re-export cycle can still have `pub` items after this PR. For example,
```rust
mod foo {
    pub fn f() {}; // (1) This defines `foo::f`.
    pub use bar::*; // (3) This is not a duplicate error since items shadow glob-imported re-exports (cf #31337).
}
mod bar {
    pub use foo::*; // (2) This defines `bar::f`.
}
```
r? @nikomatsakis

1  2 
src/librustc_resolve/resolve_imports.rs