mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 18:34:08 +00:00
Update error messages and error descriptions
This commit is contained in:
parent
26a2f852be
commit
f8ae31f601
@ -21,13 +21,14 @@ trait Foo {
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub trait Bar : Foo {} // error: private trait in exported type parameter bound
|
||||
pub trait Bar : Foo {} // error: private trait in public interface
|
||||
pub struct Bar<T: Foo>(pub T); // same error
|
||||
pub fn foo<T: Foo> (t: T) {} // same error
|
||||
```
|
||||
|
||||
To solve this error, please ensure that the trait is also public and accessible
|
||||
at the same level of the public functions or types which are bound on it.
|
||||
To solve this error, please ensure that the trait is also public. The trait
|
||||
can be made inaccessible if necessary by placing it into a private inner module,
|
||||
but it still has to be marked with `pub`.
|
||||
Example:
|
||||
|
||||
```
|
||||
@ -42,20 +43,22 @@ pub fn foo<T: Foo> (t: T) {} // ok!
|
||||
"##,
|
||||
|
||||
E0446: r##"
|
||||
A private type was used in an exported type signature. Erroneous code example:
|
||||
A private type was used in an public type signature. Erroneous code example:
|
||||
|
||||
```
|
||||
mod Foo {
|
||||
struct Bar(u32);
|
||||
|
||||
pub fn bar() -> Bar { // error: private type in exported type signature
|
||||
pub fn bar() -> Bar { // error: private type in public interface
|
||||
Bar(0)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To solve this error, please ensure that the type is also public and accessible
|
||||
at the same level of the public functions or types which use it. Example:
|
||||
To solve this error, please ensure that the type is also public. The type
|
||||
can be made inaccessible if necessary by placing it into a private inner module,
|
||||
but it still has to be marked with `pub`.
|
||||
Example:
|
||||
|
||||
```
|
||||
mod Foo {
|
||||
|
@ -1136,7 +1136,7 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a,
|
||||
if item.vis != hir::Public {
|
||||
if !self.is_quiet {
|
||||
span_err!(self.tcx.sess, ty.span, E0446,
|
||||
"private type in exported type signature");
|
||||
"private type in public interface");
|
||||
}
|
||||
self.is_public = false;
|
||||
}
|
||||
@ -1162,7 +1162,7 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a,
|
||||
if item.vis != hir::Public {
|
||||
if !self.is_quiet {
|
||||
span_err!(self.tcx.sess, trait_ref.path.span, E0445,
|
||||
"private trait in exported type parameter bound");
|
||||
"private trait in public interface");
|
||||
}
|
||||
self.is_public = false;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use std::any::TypeId;
|
||||
trait Private<P, R> {
|
||||
fn call(&self, p: P, r: R);
|
||||
}
|
||||
pub trait Public: Private< //~ ERROR private trait in exported type parameter bound
|
||||
pub trait Public: Private< //~ ERROR private trait in public interface
|
||||
<Self as Public>::P,
|
||||
<Self as Public>::R
|
||||
> {
|
||||
|
@ -20,7 +20,7 @@ trait PrivateTrait {
|
||||
}
|
||||
|
||||
impl PublicTrait for PublicType {
|
||||
type Item = PrivateType; //~ ERROR private type in exported type signature
|
||||
type Item = PrivateType; //~ ERROR private type in public interface
|
||||
}
|
||||
|
||||
// OK
|
||||
|
@ -16,7 +16,7 @@ mod y {
|
||||
struct Bar { x: u32 }
|
||||
|
||||
impl Foo {
|
||||
pub fn foo(&self, x: Self, y: Bar) { } //~ ERROR private type in exported type signature
|
||||
pub fn foo(&self, x: Self, y: Bar) { } //~ ERROR private type in public interface
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,9 +26,9 @@ mod x {
|
||||
struct Bar { _x: u32 }
|
||||
|
||||
impl Foo {
|
||||
pub fn foo(&self, _x: Self, _y: Bar) { } //~ ERROR private type in exported type signature
|
||||
pub fn foo(&self, _x: Self, _y: Bar) { } //~ ERROR private type in public interface
|
||||
pub fn bar(&self) -> Bar { Bar { _x: self.x } }
|
||||
//~^ ERROR private type in exported type signature
|
||||
//~^ ERROR private type in public interface
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,21 @@ struct Priv;
|
||||
pub use self::private::public;
|
||||
|
||||
mod private {
|
||||
pub type Priv = super::Priv; //~ ERROR private type in exported type signature
|
||||
pub type Priv = super::Priv; //~ ERROR private type in public interface
|
||||
|
||||
pub fn public(_x: Priv) {
|
||||
}
|
||||
}
|
||||
|
||||
struct __CFArray;
|
||||
pub type CFArrayRef = *const __CFArray; //~ ERROR private type in exported type signature
|
||||
pub type CFArrayRef = *const __CFArray; //~ ERROR private type in public interface
|
||||
trait Pointer { type Pointee; }
|
||||
impl<T> Pointer for *const T { type Pointee = T; }
|
||||
pub type __CFArrayRevealed = <CFArrayRef as Pointer>::Pointee;
|
||||
//~^ ERROR private type in exported type signature
|
||||
//~^ ERROR private type in public interface
|
||||
|
||||
type Foo = u8;
|
||||
pub fn foo(f: Foo) {} //~ ERROR private type in exported type signature
|
||||
pub fn foo(f: Foo) {} //~ ERROR private type in public interface
|
||||
|
||||
pub trait Exporter {
|
||||
type Output;
|
||||
@ -43,7 +43,7 @@ pub fn block() -> <Helper as Exporter>::Output {
|
||||
}
|
||||
|
||||
impl Exporter for Helper {
|
||||
type Output = Inner; //~ ERROR private type in exported type signature
|
||||
type Output = Inner; //~ ERROR private type in public interface
|
||||
}
|
||||
|
||||
Inner
|
||||
|
@ -36,17 +36,17 @@ impl Public<Private<isize>> {
|
||||
fn d() -> Private<isize> { panic!() }
|
||||
}
|
||||
impl Public<isize> {
|
||||
pub fn e(&self) -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
|
||||
pub fn e(&self) -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
fn f(&self) -> Private<isize> { panic!() }
|
||||
}
|
||||
|
||||
pub fn x(_: Private<isize>) {} //~ ERROR private type in exported type signature
|
||||
pub fn x(_: Private<isize>) {} //~ ERROR private type in public interface
|
||||
|
||||
fn y(_: Private<isize>) {}
|
||||
|
||||
|
||||
pub struct Foo {
|
||||
pub x: Private<isize>, //~ ERROR private type in exported type signature
|
||||
pub x: Private<isize>, //~ ERROR private type in public interface
|
||||
y: Private<isize>
|
||||
}
|
||||
|
||||
@ -55,9 +55,9 @@ struct Bar {
|
||||
}
|
||||
|
||||
pub enum Baz {
|
||||
Baz1(Private<isize>), //~ ERROR private type in exported type signature
|
||||
Baz1(Private<isize>), //~ ERROR private type in public interface
|
||||
Baz2 {
|
||||
y: Private<isize> //~ ERROR private type in exported type signature
|
||||
y: Private<isize> //~ ERROR private type in public interface
|
||||
},
|
||||
}
|
||||
|
||||
@ -69,14 +69,14 @@ enum Qux {
|
||||
}
|
||||
|
||||
pub trait PubTrait {
|
||||
fn foo(&self) -> Private<isize> { panic!( )} //~ ERROR private type in exported type signature
|
||||
fn bar(&self) -> Private<isize>; //~ ERROR private type in exported type signature
|
||||
fn baz() -> Private<isize>; //~ ERROR private type in exported type signature
|
||||
fn foo(&self) -> Private<isize> { panic!( )} //~ ERROR private type in public interface
|
||||
fn bar(&self) -> Private<isize>; //~ ERROR private type in public interface
|
||||
fn baz() -> Private<isize>; //~ ERROR private type in public interface
|
||||
}
|
||||
|
||||
impl PubTrait for Public<isize> {
|
||||
fn bar(&self) -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
|
||||
fn baz() -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
|
||||
fn bar(&self) -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
fn baz() -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
}
|
||||
impl PubTrait for Public<Private<isize>> {
|
||||
fn bar(&self) -> Private<isize> { panic!() }
|
||||
@ -117,7 +117,7 @@ impl ParamTrait<Private<isize>> for Private<isize> {
|
||||
fn foo() -> Private<isize> { panic!( )}
|
||||
}
|
||||
|
||||
impl<T: ParamTrait<Private<isize>>> //~ ERROR private type in exported type signature
|
||||
impl<T: ParamTrait<Private<isize>>> //~ ERROR private type in public interface
|
||||
ParamTrait<T> for Public<i8> {
|
||||
fn foo() -> T { panic!() }
|
||||
}
|
||||
|
@ -14,12 +14,12 @@
|
||||
mod a {
|
||||
struct Priv;
|
||||
|
||||
pub fn expose_a() -> Priv { //~Error: private type in exported type signature
|
||||
pub fn expose_a() -> Priv { //~Error: private type in public interface
|
||||
panic!();
|
||||
}
|
||||
|
||||
mod b {
|
||||
pub fn expose_b() -> super::Priv { //~Error: private type in exported type signature
|
||||
pub fn expose_b() -> super::Priv { //~Error: private type in public interface
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ trait Foo {
|
||||
|
||||
pub fn f<
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
>() {}
|
||||
|
||||
pub fn g<T>() where
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
{}
|
||||
|
||||
pub struct S;
|
||||
@ -27,39 +27,39 @@ pub struct S;
|
||||
impl S {
|
||||
pub fn f<
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
>() {}
|
||||
|
||||
pub fn g<T>() where
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
{}
|
||||
}
|
||||
|
||||
pub struct S1<
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
> {
|
||||
x: T
|
||||
}
|
||||
|
||||
pub struct S2<T> where
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
{
|
||||
x: T
|
||||
}
|
||||
|
||||
pub enum E1<
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
> {
|
||||
V1(T)
|
||||
}
|
||||
|
||||
pub enum E2<T> where
|
||||
T
|
||||
: Foo //~ ERROR private trait in exported type parameter bound
|
||||
: Foo //~ ERROR private trait in public interface
|
||||
{
|
||||
V2(T)
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ trait Foo {
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub trait Bar : Foo {} //~ ERROR private trait in exported type
|
||||
pub trait Bar : Foo {} //~ ERROR private trait in public interface
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user