Skip to content
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

Rust complains about "private type in public interface" even though the type and interface are both aliases. #34293

Closed
jmegaffin opened this issue Jun 16, 2016 · 1 comment

Comments

@jmegaffin
Copy link

jmegaffin commented Jun 16, 2016

use core::nonzero::NonZero;
use std::os::raw::c_void;

type Foo = NonZero<*const c_void>;

// warning: private type in public interface
pub type Bar = Foo;
// warning: private type in public interface
pub type Baz = Foo;

I also tried pub useing NonZero and c_void but that didn't help, so it's not the types themselves that are the problem. It seems bizarre that Rust would complain about this behaviour when, for example, error messages are unaware of aliases. Even if they were, it would be trivial to resolve private aliases to the public types they are defined as, so I can't see the utility of disallowing this.

My rustc --version --verbose:

rustc 1.11.0-nightly (6b4511755 2016-06-14)
binary: rustc
commit-hash: 6b4511755cfe63a46f2db8c72145e07f94911c08
commit-date: 2016-06-14
host: x86_64-unknown-linux-gnu
release: 1.11.0-nightly
@petrochenkov
Copy link
Contributor

petrochenkov commented Jun 16, 2016

There's an issue about this (#30503) and a PR fixing this (#34193).
This could be implemented more than half a year ago, it's just decision making is sometimes super slow for secondary non-prioritized features.

@jmegaffin jmegaffin reopened this Jun 16, 2016
bors added a commit that referenced this issue Aug 11, 2016
privacy: Substitute type aliases in private-in-public checker

Closes #30503
Closes #34293

Everyone in the issue discussion seemed to be in favor, @huonw also spoke about this [here](https://www.reddit.com/r/rust/comments/3xldr9/surfaces_and_signatures_component_privacy_versus/cy615wq), but the issue haven't got any movement.
I think it's reasonable to do this before turning `private_in_public` warnings into errors.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants