diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-02-23 00:22:52 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-02-26 00:37:27 +0000 |
| commit | e67590b0821c8985a02b699471d85be6d2137bff (patch) | |
| tree | 681478af55ae704d562ba112fc2e48d71cd7132c | |
| parent | 2e36a7a644ca32f7c153a5128118fcd19cc6011a (diff) | |
| download | rust-e67590b0821c8985a02b699471d85be6d2137bff.tar.gz rust-e67590b0821c8985a02b699471d85be6d2137bff.zip | |
Add tests
| -rw-r--r-- | src/test/compile-fail/privacy-in-paths.rs | 40 | ||||
| -rw-r--r-- | src/test/compile-fail/private-impl-method.rs | 7 |
2 files changed, 47 insertions, 0 deletions
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 00000000000..0a8689ea6d6 --- /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 <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 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 c6e329aab04..e04380f12ac 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 } |
