-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Don't allow priv use to shadow pub use
Previously, a private use statement would shadow a public use statement, all of a sudden publicly exporting the privately used item. The correct behavior here is to only shadow the use for the module in question, but for now it just reverts the entire name to private so the pub use doesn't have much effect. The behavior isn't exactly what we want, but this no longer has backwards compatibility hazards.
- Loading branch information
1 parent
df533c6
commit 1f2c18a
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
mod a { | ||
pub fn foobar() -> int { 1 } | ||
} | ||
|
||
mod b { | ||
pub fn foobar() -> int { 2 } | ||
} | ||
|
||
mod c { | ||
// Technically the second use shadows the first, but in theory it should | ||
// only be shadowed for this module. The implementation of resolve currently | ||
// doesn't implement this, so this test is ensuring that using "c::foobar" | ||
// is *not* getting b::foobar. Today it's an error, but perhaps one day it | ||
// can correctly get a::foobar instead. | ||
pub use a::foobar; | ||
use b::foobar; | ||
} | ||
|
||
fn main() { | ||
assert_eq!(c::foobar(), 1); | ||
//~^ ERROR: unresolved name `c::foobar` | ||
} | ||
|
1f2c18a
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.
saw approval from alexcrichton
at alexcrichton@1f2c18a
1f2c18a
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.
merging alexcrichton/rust/rollup = 1f2c18a into auto
1f2c18a
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.
alexcrichton/rust/rollup = 1f2c18a merged ok, testing candidate = 0156af1
1f2c18a
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.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5179
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5178
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4270
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4284
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5278
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4365
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4373
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5280
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4365
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4370
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4436
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2165
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5278
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4373
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4387
1f2c18a
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.
fast-forwarding master to auto = 0156af1