-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
RFC: settle rules about visibility of impls #3600
Comments
For consistency, enforcing normal module visibility rules on impls of traits makes sense, but I can't think of a reason it matters that much. From a library user's point of view, a private trait impl is the same as no trait impl. The behavior of visibility on the anonymous impl should be considered too. I'm not sure if that's understood yet either or if it's assumed to be the same. Right now 'pub' does nothing on it I think. My preference is that pub and priv everywhere mean module level visibility and everything is priv by default. Currently fields and methods are pub by default. |
Making a With private by default impls you will frequently run into the problem of forgetting to make impls public, but I'm wary of more special cases. What if we have a consistent priv by default policy everywhere, but offered policy control via attributes? |
Is there a similar issue with the visibility of traits themselves? Currently they seem to always be visible within a crate, even if marked priv. This can cause issues. For example:
Produces:
I found this surprising because I expected neither A nor B to be in scope. OTOH this may in-fact be the same issue. |
Also see #3985 |
Use non-null pointer for size 0 posix memalign Fixes rust-lang#3576
Right now, I think, an impl of trait T for type X is always visible from within a crate, but to be visible from outside a crate they must be public. I am frankly unsure if these rules are good or bad but I do believe they are to some extent accidental. We should decide when and if impls are visible.
For example, I could imagine any of the following rules:
Some related questions:
The text was updated successfully, but these errors were encountered: