-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Possible to put/expose private type in exported/public type signature #18082
Comments
The definition of public items according to the RFC is simply "something marked |
Hmm, who about this: // opaque.rs
mod inaccessible {
pub struct Struct;
impl Struct {
pub fn kaboom(self) {
unimplemented!();
}
}
}
pub fn new_thing() -> inaccessible::Struct {
inaccessible::Struct
} According to the RFC, Let's see the consequences: // app.rs
extern crate opaque;
fn main() {
let he_who_can_not_be_typed: _ = opaque::new_thing(); // what's the type of this?
he_who_can_not_be_typed.kaboom();
}
EDIT Fix variable name in method call |
Aha! I would indeed classify that link error as a bug. |
Triage: linking error still occurs |
The "private mod trick" makes this private type/trait in public signature check very optional. mod private {
pub struct Foo;
}
pub fn take_foo(_: private::Foo) { } |
Triage: linking error now goes away, and the program successfully executes. Given the age of this issue, and that that seems to be the only bug here, I"m going to give this one a close. There has been a lot of discussion around the public-in-private lint, but this isn't the issue tracking any of that. |
STR
rustc --crate-type=lib lib.rs
successfully compiles, but it should error witherror: private type in exported type signature
with span onpub right: private::Struct
.Sanity check that
private::Struct
is actually private:Errors (as expected) with:
Version
This is supposed to be banned by RFC #136
cc @pcwalton
The text was updated successfully, but these errors were encountered: