You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod foo {pubstructFoo;implFoo{pubfnnormal(&self){self.private();self.public();}}mod bar {implsuper::Foo{fnprivate(&self){}pubfnpublic(&self){self.private()}}}}fnmain(){
foo::Foo.normal();
foo::Foo.private();
foo::Foo.public();}
Compilation fails with
<anon>:5:13: 5:27 error: method `private` is private
<anon>:5 self.private();
^~~~~~~~~~~~~~
<anon>:19:5: 19:23 error: method `private` is private
<anon>:19 foo::Foo.private();
^~~~~~~~~~~~~~~~~~
(Removing those two .private calls compiles fine.)
This is inconsistent because:
private is only accessible inside bar, i.e. being private means it is being scoped with the module
public is accessible everywhere despite bar being private (if it were a freestanding function, one could only call foo::bar::public inside foo, not inside main); i.e. it appears to be being scoped with the type
I would expect both pub and non-pub methods to have the same scoping either both with the type (so foo and any descendants can call private, as well as main calling public), or both with the module (so main cannot call public).
The text was updated successfully, but these errors were encountered:
`cargo clippy --fix`
This PR is the result of running `cargo clippy --fix && cargo fmt` in the root of the repository. I did not manually review all the changes, but just skimmed through a few of them. The tests still pass, so it seems fine.
Compilation fails with
(Removing those two
.private
calls compiles fine.)This is inconsistent because:
private
is only accessible insidebar
, i.e. being private means it is being scoped with the modulepublic
is accessible everywhere despitebar
being private (if it were a freestanding function, one could only callfoo::bar::public
insidefoo
, not insidemain
); i.e. it appears to be being scoped with the typeI would expect both
pub
and non-pub
methods to have the same scoping either both with the type (sofoo
and any descendants can callprivate
, as well asmain
callingpublic
), or both with the module (somain
cannot callpublic
).The text was updated successfully, but these errors were encountered: