diff options
| author | bors <bors@rust-lang.org> | 2015-10-27 01:04:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-10-27 01:04:14 +0000 |
| commit | 95fb8d1c87907de61514a624ef62f6a6b463aefc (patch) | |
| tree | 6b4cd2289bbccf96721d8a7a5186e72e1da39358 /src | |
| parent | 05eb81ae11929438f2386d34113e45a5a2c3552b (diff) | |
| parent | 31fa9167c0046b3f225864d3e7317120694bfb8f (diff) | |
| download | rust-95fb8d1c87907de61514a624ef62f6a6b463aefc.tar.gz rust-95fb8d1c87907de61514a624ef62f6a6b463aefc.zip | |
Auto merge of #29325 - alexcrichton:revert-trait-accessibility, r=nrc
These commits revert https://github.com/rust-lang/rust/pull/28504 and add a regression test pointed out by @petrochenkov, it's not immediately clear with the regression that the accessibility check should be removed, so for now preserve the behavior on stable by default. r? @nrc
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_privacy/lib.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/trait-not-accessible.rs (renamed from src/test/run-pass/issue-16264.rs) | 23 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a004a068be4..ed8ec27705a 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -852,8 +852,12 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { ty::ImplContainer(_) => { self.check_static_method(span, method_def_id, name) } - // Trait methods are always accessible if the trait is in scope. - ty::TraitContainer(_) => {} + // Trait methods are always all public. The only controlling factor + // is whether the trait itself is accessible or not. + ty::TraitContainer(trait_def_id) => { + self.report_error(self.ensure_public(span, trait_def_id, + None, "source trait")); + } } } } diff --git a/src/test/run-pass/issue-16264.rs b/src/test/compile-fail/trait-not-accessible.rs index 67701de6386..21668fcfeae 100644 --- a/src/test/run-pass/issue-16264.rs +++ b/src/test/compile-fail/trait-not-accessible.rs @@ -8,20 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use outer::Foo; +mod m { + trait Priv { + fn f(&self) {} + } + impl Priv for super::S {} + pub trait Pub: Priv {} +} -mod outer { - pub use self::inner::Foo; +struct S; +impl m::Pub for S {} - mod inner { - pub trait Foo { - fn bar(&self) {} - } - impl Foo for i32 {} - } +fn g<T: m::Pub>(arg: T) { + arg.f(); //~ ERROR: source trait is private } fn main() { - let x: i32 = 0; - x.bar(); + g(S); } |
