diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/ui/privacy | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/privacy')
-rw-r--r-- | tests/ui/privacy/auxiliary/xc-private-method-lib.rs | 33 | ||||
-rw-r--r-- | tests/ui/privacy/effective_visibilities.rs | 7 | ||||
-rw-r--r-- | tests/ui/privacy/effective_visibilities.stderr | 66 | ||||
-rw-r--r-- | tests/ui/privacy/issue-29161.rs | 2 | ||||
-rw-r--r-- | tests/ui/privacy/issue-29161.stderr | 6 | ||||
-rw-r--r-- | tests/ui/privacy/priv-in-bad-locations.rs | 8 | ||||
-rw-r--r-- | tests/ui/privacy/priv-in-bad-locations.stderr | 20 | ||||
-rw-r--r-- | tests/ui/privacy/privacy-ns1.stderr | 6 | ||||
-rw-r--r-- | tests/ui/privacy/privacy-ns2.stderr | 6 | ||||
-rw-r--r-- | tests/ui/privacy/privacy-sanity.rs | 36 | ||||
-rw-r--r-- | tests/ui/privacy/privacy-sanity.stderr | 96 | ||||
-rw-r--r-- | tests/ui/privacy/private-in-public-assoc-ty.rs | 2 | ||||
-rw-r--r-- | tests/ui/privacy/private-in-public-type-alias-impl-trait.rs | 2 | ||||
-rw-r--r-- | tests/ui/privacy/useless-pub.rs | 6 | ||||
-rw-r--r-- | tests/ui/privacy/useless-pub.stderr | 18 | ||||
-rw-r--r-- | tests/ui/privacy/xc-private-method.rs | 11 | ||||
-rw-r--r-- | tests/ui/privacy/xc-private-method.stderr | 25 | ||||
-rw-r--r-- | tests/ui/privacy/xc-private-method2.rs | 11 | ||||
-rw-r--r-- | tests/ui/privacy/xc-private-method2.stderr | 25 |
19 files changed, 270 insertions, 116 deletions
diff --git a/tests/ui/privacy/auxiliary/xc-private-method-lib.rs b/tests/ui/privacy/auxiliary/xc-private-method-lib.rs new file mode 100644 index 000000000..4d5ec6de3 --- /dev/null +++ b/tests/ui/privacy/auxiliary/xc-private-method-lib.rs @@ -0,0 +1,33 @@ +#![crate_type="lib"] + +pub struct Struct { + pub x: isize +} + +impl Struct { + fn static_meth_struct() -> Struct { + Struct { x: 1 } + } + + fn meth_struct(&self) -> isize { + self.x + } +} + +pub enum Enum { + Variant1(isize), + Variant2(isize) +} + +impl Enum { + fn static_meth_enum() -> Enum { + Enum::Variant2(10) + } + + fn meth_enum(&self) -> isize { + match *self { + Enum::Variant1(x) | + Enum::Variant2(x) => x + } + } +} diff --git a/tests/ui/privacy/effective_visibilities.rs b/tests/ui/privacy/effective_visibilities.rs index ff20e20d3..e9ac93160 100644 --- a/tests/ui/privacy/effective_visibilities.rs +++ b/tests/ui/privacy/effective_visibilities.rs @@ -1,3 +1,4 @@ +#![rustc_effective_visibility] //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #![feature(rustc_attrs)] #[rustc_effective_visibility] @@ -17,13 +18,13 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub } #[rustc_effective_visibility] - struct PrivStruct; //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - //~| ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + struct PrivStruct; //~ ERROR not in the table + //~| ERROR not in the table #[rustc_effective_visibility] pub union PubUnion { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] - a: u8, //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + a: u8, //~ ERROR not in the table #[rustc_effective_visibility] pub b: u8, //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub } diff --git a/tests/ui/privacy/effective_visibilities.stderr b/tests/ui/privacy/effective_visibilities.stderr index 046b6095f..f74f812e1 100644 --- a/tests/ui/privacy/effective_visibilities.stderr +++ b/tests/ui/privacy/effective_visibilities.stderr @@ -1,140 +1,152 @@ +error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities.rs:1:1 + | +LL | / #![rustc_effective_visibility] +LL | | #![feature(rustc_attrs)] +LL | | +LL | | #[rustc_effective_visibility] +... | +LL | | +LL | | fn main() {} + | |____________^ + error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:4:1 + --> $DIR/effective_visibilities.rs:5:1 | LL | mod outer { | ^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:6:5 + --> $DIR/effective_visibilities.rs:7:5 | LL | pub mod inner1 { | ^^^^^^^^^^^^^^ error: not in the table - --> $DIR/effective_visibilities.rs:9:9 + --> $DIR/effective_visibilities.rs:10:9 | LL | extern "C" {} | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:12:9 + --> $DIR/effective_visibilities.rs:13:9 | LL | pub trait PubTrait { | ^^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:20:9 +error: not in the table + --> $DIR/effective_visibilities.rs:21:9 | LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:20:9 +error: not in the table + --> $DIR/effective_visibilities.rs:21:9 | LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:24:9 + --> $DIR/effective_visibilities.rs:25:9 | LL | pub union PubUnion { | ^^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:26:13 +error: not in the table + --> $DIR/effective_visibilities.rs:27:13 | LL | a: u8, | ^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:28:13 + --> $DIR/effective_visibilities.rs:29:13 | LL | pub b: u8, | ^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:32:9 + --> $DIR/effective_visibilities.rs:33:9 | LL | pub enum Enum { | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:34:13 + --> $DIR/effective_visibilities.rs:35:13 | LL | A( | ^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:34:13 + --> $DIR/effective_visibilities.rs:35:13 | LL | A( | ^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:37:17 + --> $DIR/effective_visibilities.rs:38:17 | LL | PubUnion, | ^^^^^^^^ error: not in the table - --> $DIR/effective_visibilities.rs:43:5 + --> $DIR/effective_visibilities.rs:44:5 | LL | macro_rules! none_macro { | ^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(self), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:49:5 + --> $DIR/effective_visibilities.rs:50:5 | LL | macro_rules! public_macro { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:54:5 + --> $DIR/effective_visibilities.rs:55:5 | LL | pub struct ReachableStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:56:9 + --> $DIR/effective_visibilities.rs:57:9 | LL | pub a: u8, | ^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:61:9 + --> $DIR/effective_visibilities.rs:62:9 | LL | pub use outer::inner1; | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:67:5 + --> $DIR/effective_visibilities.rs:68:5 | LL | pub type HalfPublicImport = u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:70:5 + --> $DIR/effective_visibilities.rs:71:5 | LL | pub(crate) const HalfPublicImport: u8 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:74:9 + --> $DIR/effective_visibilities.rs:75:9 | LL | pub use half_public_import::HalfPublicImport; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:14:13 + --> $DIR/effective_visibilities.rs:15:13 | LL | const A: i32; | ^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:16:13 + --> $DIR/effective_visibilities.rs:17:13 | LL | type B; | ^^^^^^ -error: aborting due to 23 previous errors +error: aborting due to 24 previous errors diff --git a/tests/ui/privacy/issue-29161.rs b/tests/ui/privacy/issue-29161.rs index d80405aa8..5c926dee0 100644 --- a/tests/ui/privacy/issue-29161.rs +++ b/tests/ui/privacy/issue-29161.rs @@ -2,7 +2,7 @@ mod a { struct A; impl Default for A { - pub fn default() -> A { //~ ERROR unnecessary visibility qualifier + pub fn default() -> A { //~ ERROR visibility qualifiers are not permitted here A } } diff --git a/tests/ui/privacy/issue-29161.stderr b/tests/ui/privacy/issue-29161.stderr index 7ce95e4b0..1a6c80499 100644 --- a/tests/ui/privacy/issue-29161.stderr +++ b/tests/ui/privacy/issue-29161.stderr @@ -1,8 +1,10 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/issue-29161.rs:5:9 | LL | pub fn default() -> A { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error[E0603]: struct `A` is private --> $DIR/issue-29161.rs:13:8 diff --git a/tests/ui/privacy/priv-in-bad-locations.rs b/tests/ui/privacy/priv-in-bad-locations.rs index 76af8c6cd..32c5b801f 100644 --- a/tests/ui/privacy/priv-in-bad-locations.rs +++ b/tests/ui/privacy/priv-in-bad-locations.rs @@ -1,4 +1,4 @@ -pub extern "C" { //~ ERROR unnecessary visibility qualifier +pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn bar(); } @@ -8,10 +8,10 @@ trait A { struct B; -pub impl B {} //~ ERROR unnecessary visibility qualifier +pub impl B {} //~ ERROR visibility qualifiers are not permitted here -pub impl A for B { //~ ERROR unnecessary visibility qualifier - pub fn foo(&self) {} //~ ERROR unnecessary visibility qualifier +pub impl A for B { //~ ERROR visibility qualifiers are not permitted here + pub fn foo(&self) {} //~ ERROR visibility qualifiers are not permitted here } pub fn main() {} diff --git a/tests/ui/privacy/priv-in-bad-locations.stderr b/tests/ui/privacy/priv-in-bad-locations.stderr index 75bd2fe47..70dab5bfe 100644 --- a/tests/ui/privacy/priv-in-bad-locations.stderr +++ b/tests/ui/privacy/priv-in-bad-locations.stderr @@ -1,30 +1,34 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:1:1 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:11:1 | LL | pub impl B {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:13:1 | LL | pub impl A for B { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:14:5 | LL | pub fn foo(&self) {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to 4 previous errors diff --git a/tests/ui/privacy/privacy-ns1.stderr b/tests/ui/privacy/privacy-ns1.stderr index 91bc84e70..9710cc486 100644 --- a/tests/ui/privacy/privacy-ns1.stderr +++ b/tests/ui/privacy/privacy-ns1.stderr @@ -13,7 +13,7 @@ LL | Baz(); | ~~~ help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0425]: cannot find function, tuple struct or tuple variant `Bar` in this scope @@ -31,7 +31,7 @@ LL | Baz(); | ~~~ help: consider importing this function | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0412]: cannot find type `Bar` in this scope @@ -49,7 +49,7 @@ LL | let _x: Box<Baz>; | ~~~ help: consider importing this trait | -LL | use foo1::Bar; +LL + use foo1::Bar; | error[E0747]: constant provided when a type was expected diff --git a/tests/ui/privacy/privacy-ns2.stderr b/tests/ui/privacy/privacy-ns2.stderr index 904e9013f..75e735e1e 100644 --- a/tests/ui/privacy/privacy-ns2.stderr +++ b/tests/ui/privacy/privacy-ns2.stderr @@ -6,7 +6,7 @@ LL | Bar(); | help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` @@ -24,7 +24,7 @@ LL | Baz(); | ~~~ help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0573]: expected type, found function `Bar` @@ -39,7 +39,7 @@ LL | let _x = Bar(); | ~ help: consider importing this trait instead | -LL | use foo1::Bar; +LL + use foo1::Bar; | error[E0603]: trait `Bar` is private diff --git a/tests/ui/privacy/privacy-sanity.rs b/tests/ui/privacy/privacy-sanity.rs index 8bbf1ab5d..6622089dd 100644 --- a/tests/ui/privacy/privacy-sanity.rs +++ b/tests/ui/privacy/privacy-sanity.rs @@ -10,17 +10,17 @@ pub struct S { } struct Ts(pub u8); -pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier +pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } -pub impl S { //~ ERROR unnecessary visibility qualifier +pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } -pub extern "C" { //~ ERROR unnecessary visibility qualifier +pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } @@ -36,17 +36,17 @@ const MAIN: u8 = { } struct Ts(pub u8); - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier + pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } - pub impl S { //~ ERROR unnecessary visibility qualifier + pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } - pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } @@ -65,17 +65,17 @@ fn main() { } struct Ts(pub u8); - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier + pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } - pub impl S { //~ ERROR unnecessary visibility qualifier + pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } - pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } diff --git a/tests/ui/privacy/privacy-sanity.stderr b/tests/ui/privacy/privacy-sanity.stderr index c92553fd1..a537f8c19 100644 --- a/tests/ui/privacy/privacy-sanity.stderr +++ b/tests/ui/privacy/privacy-sanity.stderr @@ -1,120 +1,144 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:13:1 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:14:5 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:15:5 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:16:5 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:18:1 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:23:1 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:39:5 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:40:9 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:41:9 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:42:9 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:44:5 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:49:5 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:68:5 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:69:9 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:70:9 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:71:9 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:73:5 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:78:5 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead diff --git a/tests/ui/privacy/private-in-public-assoc-ty.rs b/tests/ui/privacy/private-in-public-assoc-ty.rs index fba72c131..d4d379bdb 100644 --- a/tests/ui/privacy/private-in-public-assoc-ty.rs +++ b/tests/ui/privacy/private-in-public-assoc-ty.rs @@ -2,7 +2,7 @@ // This test also ensures that the checks are performed even inside private modules. #![feature(associated_type_defaults)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] mod m { struct Priv; diff --git a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs index c7df31529..fe6ed4673 100644 --- a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs +++ b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs @@ -1,5 +1,5 @@ // build-pass (FIXME(62277): could be check-pass?) - +#![feature(impl_trait_in_assoc_type)] #![feature(type_alias_impl_trait)] #![deny(private_in_public)] diff --git a/tests/ui/privacy/useless-pub.rs b/tests/ui/privacy/useless-pub.rs index fde7cd5d8..e4b671142 100644 --- a/tests/ui/privacy/useless-pub.rs +++ b/tests/ui/privacy/useless-pub.rs @@ -5,12 +5,12 @@ pub trait E { } impl E for A { - pub fn foo(&self) {} //~ ERROR: unnecessary visibility qualifier + pub fn foo(&self) {} //~ ERROR: visibility qualifiers are not permitted here } enum Foo { - V1 { pub f: i32 }, //~ ERROR unnecessary visibility qualifier - V2(pub i32), //~ ERROR unnecessary visibility qualifier + V1 { pub f: i32 }, //~ ERROR visibility qualifiers are not permitted here + V2(pub i32), //~ ERROR visibility qualifiers are not permitted here } fn main() {} diff --git a/tests/ui/privacy/useless-pub.stderr b/tests/ui/privacy/useless-pub.stderr index 14c4983ae..73497e3fe 100644 --- a/tests/ui/privacy/useless-pub.stderr +++ b/tests/ui/privacy/useless-pub.stderr @@ -1,20 +1,26 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:8:5 | LL | pub fn foo(&self) {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:12:10 | LL | V1 { pub f: i32 }, - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:13:8 | LL | V2(pub i32), - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in error: aborting due to 3 previous errors diff --git a/tests/ui/privacy/xc-private-method.rs b/tests/ui/privacy/xc-private-method.rs new file mode 100644 index 000000000..f05994646 --- /dev/null +++ b/tests/ui/privacy/xc-private-method.rs @@ -0,0 +1,11 @@ +// aux-build:xc-private-method-lib.rs + +extern crate xc_private_method_lib; + +fn main() { + let _ = xc_private_method_lib::Struct::static_meth_struct(); + //~^ ERROR: associated function `static_meth_struct` is private + + let _ = xc_private_method_lib::Enum::static_meth_enum(); + //~^ ERROR: associated function `static_meth_enum` is private +} diff --git a/tests/ui/privacy/xc-private-method.stderr b/tests/ui/privacy/xc-private-method.stderr new file mode 100644 index 000000000..0eabc592a --- /dev/null +++ b/tests/ui/privacy/xc-private-method.stderr @@ -0,0 +1,25 @@ +error[E0624]: associated function `static_meth_struct` is private + --> $DIR/xc-private-method.rs:6:44 + | +LL | let _ = xc_private_method_lib::Struct::static_meth_struct(); + | ^^^^^^^^^^^^^^^^^^ private associated function + | + ::: $DIR/auxiliary/xc-private-method-lib.rs:8:5 + | +LL | fn static_meth_struct() -> Struct { + | --------------------------------- private associated function defined here + +error[E0624]: associated function `static_meth_enum` is private + --> $DIR/xc-private-method.rs:9:42 + | +LL | let _ = xc_private_method_lib::Enum::static_meth_enum(); + | ^^^^^^^^^^^^^^^^ private associated function + | + ::: $DIR/auxiliary/xc-private-method-lib.rs:23:5 + | +LL | fn static_meth_enum() -> Enum { + | ----------------------------- private associated function defined here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/privacy/xc-private-method2.rs b/tests/ui/privacy/xc-private-method2.rs new file mode 100644 index 000000000..f11b25108 --- /dev/null +++ b/tests/ui/privacy/xc-private-method2.rs @@ -0,0 +1,11 @@ +// aux-build:xc-private-method-lib.rs + +extern crate xc_private_method_lib; + +fn main() { + let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); + //~^ ERROR method `meth_struct` is private + + let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum(); + //~^ ERROR method `meth_enum` is private +} diff --git a/tests/ui/privacy/xc-private-method2.stderr b/tests/ui/privacy/xc-private-method2.stderr new file mode 100644 index 000000000..af0c3cfcb --- /dev/null +++ b/tests/ui/privacy/xc-private-method2.stderr @@ -0,0 +1,25 @@ +error[E0624]: method `meth_struct` is private + --> $DIR/xc-private-method2.rs:6:52 + | +LL | let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); + | ^^^^^^^^^^^ private method + | + ::: $DIR/auxiliary/xc-private-method-lib.rs:12:5 + | +LL | fn meth_struct(&self) -> isize { + | ------------------------------ private method defined here + +error[E0624]: method `meth_enum` is private + --> $DIR/xc-private-method2.rs:9:55 + | +LL | let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum(); + | ^^^^^^^^^ private method + | + ::: $DIR/auxiliary/xc-private-method-lib.rs:27:5 + | +LL | fn meth_enum(&self) -> isize { + | ---------------------------- private method defined here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0624`. |