resolve: Improve duplicate glob detection#32814
Merged
bors merged 4 commits intorust-lang:masterfrom Apr 13, 2016
Merged
Conversation
Contributor
Author
|
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. |
| // 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(()); } |
Contributor
Author
There was a problem hiding this comment.
This line was preventing the duplicate errors from being reported.
Closed
Contributor
|
r=me w/ comments |
Collaborator
|
📌 Commit c0b3bb9 has been approved by |
c0b3bb9 to
bc6daea
Compare
Contributor
Author
|
@bors r=nikomatsakis |
Collaborator
|
📌 Commit bc6daea has been approved by |
Contributor
|
This needs backport if it wants to get in Rust 1.9 beta |
Collaborator
|
⌛ Testing commit bc6daea with merge 4b71f8d... |
bors
added a commit
that referenced
this pull request
Apr 13, 2016
…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
Collaborator
This was referenced Apr 13, 2016
Contributor
|
Fixes a regression, small patch. Approved for beta. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pubitems after this PR. For example,r? @nikomatsakis