summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmutability
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /tests/ui/transmutability
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/transmutability')
-rw-r--r--tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs4
-rw-r--r--tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr19
-rw-r--r--tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs4
-rw-r--r--tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr19
4 files changed, 28 insertions, 18 deletions
diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs
index 546fcbaa3..b61291633 100644
--- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs
+++ b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs
@@ -1,3 +1,5 @@
+// check-pass
+
//! If visibility is assumed, a transmutation should be accepted even if the
//! destination type contains an unreachable field (e.g., a public field with a
//! private type). (This rule is distinct from type privacy, which still may
@@ -29,7 +31,7 @@ mod dst {
#[repr(C)] pub(self) struct Zst; // <- unreachable type
#[repr(C)] pub(in super) struct Dst {
- pub(in super) field: Zst, //~ ERROR private type
+ pub(in super) field: Zst, //~ WARNING type `dst::Zst` is more private than the item `Dst::field`
}
}
diff --git a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr
index be83b7ce3..80099388d 100644
--- a/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr
+++ b/tests/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr
@@ -1,12 +1,15 @@
-error[E0446]: private type `dst::Zst` in public interface
- --> $DIR/should_accept_if_dst_has_unreachable_field.rs:32:9
+warning: type `dst::Zst` is more private than the item `Dst::field`
+ --> $DIR/should_accept_if_dst_has_unreachable_field.rs:34:9
|
-LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type
- | -------------------- `dst::Zst` declared as private
-...
LL | pub(in super) field: Zst,
- | ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ field `Dst::field` is reachable at visibility `pub(crate)`
+ |
+note: but type `dst::Zst` is only usable at visibility `pub(self)`
+ --> $DIR/should_accept_if_dst_has_unreachable_field.rs:31:16
+ |
+LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type
+ | ^^^^^^^^^^^^^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
-error: aborting due to previous error
+warning: 1 warning emitted
-For more information about this error, try `rustc --explain E0446`.
diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs
index 9c8345a8e..e7742058c 100644
--- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs
+++ b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs
@@ -1,3 +1,5 @@
+// check-pass
+
//! The presence of an unreachable field in the source type (e.g., a public
//! field with a private type does not affect transmutability. (This rule is
//! distinct from type privacy, which still may forbid naming such types.)
@@ -19,7 +21,7 @@ mod src {
#[repr(C)] pub(self) struct Zst; // <- unreachable type
#[repr(C)] pub(in super) struct Src {
- pub(in super) field: Zst, //~ ERROR private type
+ pub(in super) field: Zst, //~ WARNING type `src::Zst` is more private than the item `Src::field`
}
}
diff --git a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr
index 39b73302e..55fb33923 100644
--- a/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr
+++ b/tests/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr
@@ -1,12 +1,15 @@
-error[E0446]: private type `src::Zst` in public interface
- --> $DIR/should_accept_if_src_has_unreachable_field.rs:22:9
+warning: type `src::Zst` is more private than the item `Src::field`
+ --> $DIR/should_accept_if_src_has_unreachable_field.rs:24:9
|
-LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type
- | -------------------- `src::Zst` declared as private
-...
LL | pub(in super) field: Zst,
- | ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ field `Src::field` is reachable at visibility `pub(crate)`
+ |
+note: but type `src::Zst` is only usable at visibility `pub(self)`
+ --> $DIR/should_accept_if_src_has_unreachable_field.rs:21:16
+ |
+LL | #[repr(C)] pub(self) struct Zst; // <- unreachable type
+ | ^^^^^^^^^^^^^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
-error: aborting due to previous error
+warning: 1 warning emitted
-For more information about this error, try `rustc --explain E0446`.