summaryrefslogtreecommitdiffstats
path: root/tests/ui/pub
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /tests/ui/pub
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/pub')
-rw-r--r--tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs16
-rw-r--r--tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr49
2 files changed, 61 insertions, 4 deletions
diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs
index 67f888c5e..cdeea6224 100644
--- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs
+++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs
@@ -1,15 +1,25 @@
+#![feature(type_privacy_lints)]
#![allow(non_camel_case_types)] // genus is always capitalized
+#![warn(private_interfaces)]
+//~^ NOTE the lint level is defined here
+
+// In this test both old and new private-in-public diagnostic were emitted.
+// Old diagnostic will be deleted soon.
+// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
pub(crate) struct Snail;
//~^ NOTE `Snail` declared as private
+//~| NOTE but type `Snail` is only usable at visibility `pub(crate)`
mod sea {
pub(super) struct Turtle;
//~^ NOTE `Turtle` declared as crate-private
+ //~| NOTE but type `Turtle` is only usable at visibility `pub(crate)`
}
struct Tortoise;
//~^ NOTE `Tortoise` declared as private
+//~| NOTE but type `Tortoise` is only usable at visibility `pub(crate)`
pub struct Shell<T> {
pub(crate) creature: T,
@@ -17,12 +27,18 @@ pub struct Shell<T> {
pub type Helix_pomatia = Shell<Snail>;
//~^ ERROR private type `Snail` in public interface
+//~| WARNING type `Snail` is more private than the item `Helix_pomatia`
//~| NOTE can't leak private type
+//~| NOTE type alias `Helix_pomatia` is reachable at visibility `pub`
pub type Dermochelys_coriacea = Shell<sea::Turtle>;
//~^ ERROR crate-private type `Turtle` in public interface
+//~| WARNING type `Turtle` is more private than the item `Dermochelys_coriacea`
//~| NOTE can't leak crate-private type
+//~| NOTE type alias `Dermochelys_coriacea` is reachable at visibility `pub`
pub type Testudo_graeca = Shell<Tortoise>;
//~^ ERROR private type `Tortoise` in public interface
+//~| WARNING type `Tortoise` is more private than the item `Testudo_graeca`
//~| NOTE can't leak private type
+//~| NOTE type alias `Testudo_graeca` is reachable at visibility `pub`
fn main() {}
diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr
index 39d4f5ac8..20e51e190 100644
--- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr
+++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr
@@ -1,5 +1,5 @@
error[E0446]: private type `Snail` in public interface
- --> $DIR/issue-33174-restricted-type-in-public-interface.rs:18:1
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1
|
LL | pub(crate) struct Snail;
| ----------------------- `Snail` declared as private
@@ -7,8 +7,25 @@ LL | pub(crate) struct Snail;
LL | pub type Helix_pomatia = Shell<Snail>;
| ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+warning: type `Snail` is more private than the item `Helix_pomatia`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1
+ |
+LL | pub type Helix_pomatia = Shell<Snail>;
+ | ^^^^^^^^^^^^^^^^^^^^^^ type alias `Helix_pomatia` is reachable at visibility `pub`
+ |
+note: but type `Snail` is only usable at visibility `pub(crate)`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:10:1
+ |
+LL | pub(crate) struct Snail;
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+note: the lint level is defined here
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:3:9
+ |
+LL | #![warn(private_interfaces)]
+ | ^^^^^^^^^^^^^^^^^^
+
error[E0446]: crate-private type `Turtle` in public interface
- --> $DIR/issue-33174-restricted-type-in-public-interface.rs:21:1
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1
|
LL | pub(super) struct Turtle;
| ------------------------ `Turtle` declared as crate-private
@@ -16,8 +33,20 @@ LL | pub(super) struct Turtle;
LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
+warning: type `Turtle` is more private than the item `Dermochelys_coriacea`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1
+ |
+LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type alias `Dermochelys_coriacea` is reachable at visibility `pub`
+ |
+note: but type `Turtle` is only usable at visibility `pub(crate)`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:15:5
+ |
+LL | pub(super) struct Turtle;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
error[E0446]: private type `Tortoise` in public interface
- --> $DIR/issue-33174-restricted-type-in-public-interface.rs:24:1
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1
|
LL | struct Tortoise;
| --------------- `Tortoise` declared as private
@@ -25,6 +54,18 @@ LL | struct Tortoise;
LL | pub type Testudo_graeca = Shell<Tortoise>;
| ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-error: aborting due to 3 previous errors
+warning: type `Tortoise` is more private than the item `Testudo_graeca`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1
+ |
+LL | pub type Testudo_graeca = Shell<Tortoise>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^ type alias `Testudo_graeca` is reachable at visibility `pub`
+ |
+note: but type `Tortoise` is only usable at visibility `pub(crate)`
+ --> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1
+ |
+LL | struct Tortoise;
+ | ^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors; 3 warnings emitted
For more information about this error, try `rustc --explain E0446`.