diff options
| -rw-r--r-- | src/librustc/middle/resolve.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/test.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/resolve-priv-shadowing-pub.rs | 33 |
3 files changed, 34 insertions, 1 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 8240068979c..38eab354f2b 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1982,6 +1982,7 @@ impl<'a> Resolver<'a> { // the source of this name is different now resolution.type_id.set(id); resolution.value_id.set(id); + resolution.is_public.set(is_public); } None => { debug!("(building import directive) creating new"); diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 14b9b5c1e06..dd874fecc52 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -39,7 +39,6 @@ macro_rules! iotest ( use io::process::*; use unstable::running_on_valgrind; use str; - use util; fn f() $b diff --git a/src/test/compile-fail/resolve-priv-shadowing-pub.rs b/src/test/compile-fail/resolve-priv-shadowing-pub.rs new file mode 100644 index 00000000000..0830722f969 --- /dev/null +++ b/src/test/compile-fail/resolve-priv-shadowing-pub.rs @@ -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` +} + |
