summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmutability/visibility
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/transmutability/visibility')
-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`.