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

Spurious private-in-public error for impl block #59090

Closed
joshlf opened this issue Mar 11, 2019 · 2 comments
Closed

Spurious private-in-public error for impl block #59090

joshlf opened this issue Mar 11, 2019 · 2 comments

Comments

@joshlf
Copy link
Contributor

joshlf commented Mar 11, 2019

The following code results in a private-in-public error:

pub(crate) trait Foo {}

pub struct Bar<T>(T);

impl<T: Foo> Bar<T> {
    pub(crate) fn new(t: T) -> Bar<T> {
        Bar(t)
    }
}
error[E0445]: crate-visible trait `Foo` in public interface
 --> src/lib.rs:5:1
  |
1 |   pub(crate) trait Foo {}
  |   ---------- `Foo` declared as crate-visible
...
5 | / impl<T: Foo> Bar<T> {
6 | |     pub(crate) fn new(t: T) -> Bar<T> {
7 | |         Bar(t)
8 | |     }
9 | | }
  | |_^ can't leak crate-visible trait

This seems wrong to me; though the impl block is on a public type, none of the methods in it are public.

@petrochenkov
Copy link
Contributor

This currently works as expected, but #48054 is going to change the rules once implemented, so the error will no longer be reported.

@joshlf
Copy link
Contributor Author

joshlf commented Mar 11, 2019

OK, sounds good, thanks!

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