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
This commit is contained in:
commit
95fb8d1c87
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,20 +8,21 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use outer::Foo;
|
||||
|
||||
mod outer {
|
||||
pub use self::inner::Foo;
|
||||
|
||||
mod inner {
|
||||
pub trait Foo {
|
||||
fn bar(&self) {}
|
||||
}
|
||||
impl Foo for i32 {}
|
||||
mod m {
|
||||
trait Priv {
|
||||
fn f(&self) {}
|
||||
}
|
||||
impl Priv for super::S {}
|
||||
pub trait Pub: Priv {}
|
||||
}
|
||||
|
||||
struct S;
|
||||
impl m::Pub for S {}
|
||||
|
||||
fn g<T: m::Pub>(arg: T) {
|
||||
arg.f(); //~ ERROR: source trait is private
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: i32 = 0;
|
||||
x.bar();
|
||||
g(S);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user