Closed
Description
openedon Sep 19, 2015
I'm not 100% sure how the privacy rules should work.
A's methods should not be callable because the trait is private, but it's reachable though the trait C that inherits A, by calling C::a()
.
B's methods are reachable the same way, even if it's marked pub but not publically reachable.
pub use inner::C;
mod inner {
trait A {
fn a(&self) { }
}
pub trait B {
fn b(&self) { }
}
pub trait C: A + B {
fn c(&self) { }
}
impl A for i32 {}
impl B for i32 {}
impl C for i32 {}
}
fn main() {
// A is private
// B is pub, not reexported
// C : A + B is pub, reexported
// 0.a(); // can't call
// 0.b(); // can't call
0.c(); // ok
C::a(&0); // can call
C::b(&0); // can call
C::c(&0); // ok
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Name resolutionArea: Name resolutionArea: Visibility / privacyArea: Visibility / privacyRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.