diff --git a/src/test/compile-fail/privacy-in-paths.rs b/src/test/compile-fail/privacy-in-paths.rs new file mode 100644 index 000000000000..0a8689ea6d61 --- /dev/null +++ b/src/test/compile-fail/privacy-in-paths.rs @@ -0,0 +1,40 @@ +// Copyright 2016 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub use self::bar::S; + mod bar { + pub struct S; + pub use baz; + } + + trait T { + type Assoc; + } + impl T for () { + type Assoc = S; + } +} + +impl foo::S { + fn f() {} +} + +pub mod baz { + fn f() {} + + fn g() { + ::foo::bar::baz::f(); //~ERROR module `bar` is private + ::foo::bar::S::f(); //~ERROR module `bar` is private + <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private + } +} + +fn main() {} diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs index c6e329aab041..e04380f12aca 100644 --- a/src/test/compile-fail/private-impl-method.rs +++ b/src/test/compile-fail/private-impl-method.rs @@ -18,7 +18,14 @@ mod a { } } +fn f() { + impl a::Foo { + fn bar(&self) {} // This should be visible outside `f` + } +} + fn main() { let s = a::Foo { x: 1 }; + s.bar(); s.foo(); //~ ERROR method `foo` is private }