Skip to content

private_in_public warning for private methods #40844

Closed
@bluss

Description

@bluss

The private in public warning triggers even for impl blocks that have no public methods. See code below to reproduce.

#![crate_type="lib"]

trait PrivateTrait {
}

pub struct Foo<T>(T);

impl<T: PrivateTrait> Foo<T> {
    fn new() -> Self {
        panic!()
    }
}

warning:

rustc 1.17.0-nightly (49c67bd63 2017-03-24)
warning: private trait `PrivateTrait` in public interface (error E0445)
  --> <anon>:8:1
   |
8  |   impl<T: PrivateTrait> Foo<T> {
   |  _^ starting here...
9  | |     fn new() -> Self {
10 | |         panic!()
11 | |     }
12 | | }
   | |_^ ...ending here
   |
   = note: #[warn(private_in_public)] on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>

cc @petrochenkov, you probably know if this is as designed or not

Metadata

Metadata

Assignees

Labels

A-visibilityArea: Visibility / privacy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions