1
Fork 0

Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkov

Replace old private-in-public diagnostic with type privacy lints

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
This commit is contained in:
bors 2023-09-01 12:40:01 +00:00
commit 1accf068d8
68 changed files with 862 additions and 1700 deletions

View file

@ -1,10 +1,10 @@
#### Note: this error code is no longer emitted by the compiler.
A private trait was used on a public type parameter bound.
Erroneous code examples:
```compile_fail,E0445
#![deny(private_in_public)]
Previously erroneous code examples:
```
trait Foo {
fn dummy(&self) { }
}

View file

@ -1,16 +1,16 @@
A private type was used in a public type signature.
A private type or trait was used in a public associated type signature.
Erroneous code example:
```compile_fail,E0446
#![deny(private_in_public)]
struct Bar(u32);
struct Bar;
mod foo {
use crate::Bar;
pub fn bar() -> Bar { // error: private type in public interface
Bar(0)
}
pub trait PubTr {
type Alias;
}
impl PubTr for u8 {
type Alias = Bar; // error private type in public interface
}
fn main() {}
@ -22,13 +22,14 @@ This is done by using pub(crate) or pub(in crate::my_mod::etc)
Example:
```
struct Bar(u32);
struct Bar;
mod foo {
use crate::Bar;
pub(crate) fn bar() -> Bar { // only public to crate root
Bar(0)
}
pub(crate) trait PubTr { // only public to crate root
type Alias;
}
impl PubTr for u8 {
type Alias = Bar;
}
fn main() {}
@ -38,12 +39,15 @@ The other way to solve this error is to make the private type public.
Example:
```
pub struct Bar(u32); // we set the Bar type public
mod foo {
use crate::Bar;
pub fn bar() -> Bar { // ok!
Bar(0)
}
pub struct Bar; // we set the Bar trait public
pub trait PubTr {
type Alias;
}
impl PubTr for u8 {
type Alias = Bar;
}
fn main() {}