-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Private type in exported type signature when it shouldn't #23585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Probably related to #23290 #22261 cc @nrc @nikomatsakis then |
I believe that this is intentional behavior, this is a safeguard against reexporting pub use A::foo;
mod A {
pub use A::B::foo;
struct X;
mod B {
pub fn foo(_: super::X) {}
}
} |
Shouldn't the reexport trigger an error then? This removes a lot of flexibility in the modules system. |
This is indeed intended behaviour (although not optimal). Basically, we have a very simple rule which is safe - public signatures can never include public types. There is a more optimal rule which we might implement in the future which takes in to account the privateness of the modules (see discussion on the bugs). The re-export is not an error because it is not public - it is perfectly fine to use X inside B in private fns, etc. |
That is disappointing, I was convinced that it was a bug. |
Also, this compiles when it shouldn't: mod B {
pub use self::A::foo;
mod A {
pub struct X;
pub fn foo(_: X) {}
}
}
This new rule is too restrictive and doesn't even totally protect you. |
I filed #23621 for the bug above |
This code:
Triggers:
The
foo
function is only visible toA
andB
, andX
is also visible to bothA
andB
, so I don't see why this would be forbidden.This was introduced in the
rustc 1.0.0-nightly (f4e0ce66a 2015-03-19) (built 2015-03-20)
nightly. With the 2015-03-17, this works.The text was updated successfully, but these errors were encountered: