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 a {pubmod x {pubfnreturn_x() -> ::X{::X}}}structX;fnmain(){let _value = a::x::return_x();}
It fails to compile with the following error:
test.rs:3:30: 3:33 error: private type in exported type signature
test.rs:3 pub fn return_x() -> ::X { ::X }
^~~
However, while fn return_x() is pub and mod x is also pub, this function never gets exported from the crate because mod a is private. Therefore, X, being private, is also not available outside the crate. I think that such code should be allowed.
The text was updated successfully, but these errors were encountered:
mod foo {// Private implementation detail structstructStrut;fndoit(){self::bar::fun();}mod bar {// bar::fun() is a private implementation detail of mod foopubfnfun() -> super::Strut{unimplemented!()}}}fnmain(){// foo::bar::fun(); // inaccessible outside of `foo`}
<anon>:9:25: 9:37 error: private type in exported type signature
<anon>:9 pub fn fun() -> super::Strut {
^~~~~~~~~~~~
This has been filed before and the gist is that the definition of a "public signature" is that the type is marked pub, so it's considered a public type subject to the privacy rules. You can find more details in the associated RFC
Consider this code:
It fails to compile with the following error:
However, while
fn return_x()
ispub
andmod x
is alsopub
, this function never gets exported from the crate becausemod a
is private. Therefore,X
, being private, is also not available outside the crate. I think that such code should be allowed.The text was updated successfully, but these errors were encountered: