-
Notifications
You must be signed in to change notification settings - Fork 13.4k
resolve: Improve duplicate glob detection #32814
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
resolve: Improve duplicate glob detection #32814
Conversation
The bug isn't in beta yet, but it landed a month ago so it still might be a good idea to do a crater run. |
@@ -275,7 +275,6 @@ impl<'a> ::ModuleS<'a> { | |||
// Define the name or return the existing binding if there is a collision. | |||
pub fn try_define_child(&self, name: Name, ns: Namespace, binding: NameBinding<'a>) | |||
-> Result<(), &'a NameBinding<'a>> { | |||
if self.resolutions.borrow_state() != ::std::cell::BorrowState::Unused { return Ok(()); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was preventing the duplicate errors from being reported.
r=me w/ comments |
📌 Commit c0b3bb9 has been approved by |
c0b3bb9
to
bc6daea
Compare
@bors r=nikomatsakis |
📌 Commit bc6daea has been approved by |
This needs backport if it wants to get in Rust 1.9 beta |
⌛ Testing commit bc6daea with merge 4b71f8d... |
…nikomatsakis 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
Fixes a regression, small patch. Approved for beta. |
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,
A module in a glob re-export cycle can still have
pub
items after this PR. For example,r? @nikomatsakis