diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/transmutability/visibility | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/transmutability/visibility')
22 files changed, 0 insertions, 698 deletions
diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs deleted file mode 100644 index 8a41669c6..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_field.rs +++ /dev/null @@ -1,38 +0,0 @@ -// check-pass -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains a private field. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(self) field: Zst, // <- private field - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs deleted file mode 100644 index dd57b877d..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_private_variant.rs +++ /dev/null @@ -1,39 +0,0 @@ -// check-pass -//! If visibility is assumed, a transmutation should be accepted even if the -//! destination type contains a private variant. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Dst { - pub(self) field: Zst, // <- private variant - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs deleted file mode 100644 index ebce8ce87..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_tricky_unreachable_field.rs +++ /dev/null @@ -1,46 +0,0 @@ -// check-pass -//! Unless visibility is assumed, a transmutation should be rejected 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 -//! forbid naming such types.) -//! -//! This test exercises a tricky-to-implement instance of this principle: the -//! "pub-in-priv trick". In the below example, the type `dst::private::Zst` is -//! unreachable from `Context`. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - mod private { - #[repr(C)] pub struct Zst; // <- unreachable type - } - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: private::Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs deleted file mode 100644 index 546fcbaa3..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! 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 -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -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 - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr deleted file mode 100644 index be83b7ce3..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0446]: private type `dst::Zst` in public interface - --> $DIR/should_accept_if_dst_has_unreachable_field.rs:32: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 - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs deleted file mode 100644 index b9b74d183..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! 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 -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> - // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^ - {} -} - -mod src { - #[repr(C)] pub(self) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); //~ ERROR `Dst` is private -} diff --git a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr b/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr deleted file mode 100644 index 827df05de..000000000 --- a/src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0603]: struct `Dst` is private - --> $DIR/should_accept_if_dst_has_unreachable_ty.rs:39:46 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^ private struct - | -note: the struct `Dst` is defined here - --> $DIR/should_accept_if_dst_has_unreachable_ty.rs:32:16 - | -LL | #[repr(C)] pub(self) struct Dst { - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs deleted file mode 100644 index 5a0df09d4..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_field.rs +++ /dev/null @@ -1,37 +0,0 @@ -// check-pass -//! The presence of a private field in the source type does not affect -//! transmutability. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(self) field: Zst, // <- private field - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs deleted file mode 100644 index 0f69630cc..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs +++ /dev/null @@ -1,38 +0,0 @@ -// check-pass -//! The presence of a private variant in the source type does not affect -//! transmutability. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Src { - pub(self) field: Zst, // <- private variant - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs deleted file mode 100644 index 9c8345a8e..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! 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.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -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 - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr deleted file mode 100644 index 39b73302e..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_field.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0446]: private type `src::Zst` in public interface - --> $DIR/should_accept_if_src_has_unreachable_field.rs:22: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 - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs deleted file mode 100644 index acf9f2302..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! The presence of an unreachable source type (i.e., the source type is -//! private) does not affect transmutability. (This rule is distinct from type -//! privacy, which still may forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); //~ ERROR `Src` is private -} diff --git a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr b/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr deleted file mode 100644 index 76dc7f340..000000000 --- a/src/test/ui/transmutability/visibility/should_accept_if_src_has_unreachable_ty.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0603]: struct `Src` is private - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:37:36 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^ private struct - | -note: the struct `Src` is defined here - --> $DIR/should_accept_if_src_has_unreachable_ty.rs:22:16 - | -LL | #[repr(C)] pub(self) struct Src { - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs deleted file mode 100644 index e8c3fbc9a..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains a private field. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Dst { - pub(self) field: Zst, // <- private field - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); //~ ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr deleted file mode 100644 index d5d6d431b..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_private_field.rs:35:41 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_private_field.rs:13:14 - | -LL | pub fn is_transmutable<Src, Dst, Context>() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs deleted file mode 100644 index 47bca27ab..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected if the -//! destination type contains a private variant. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[derive(Copy, Clone)] - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) union Dst { - pub(self) field: Zst, // <- private variant - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); //~ ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr deleted file mode 100644 index a1ca2ced5..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_private_variant.rs:36:41 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_private_variant.rs:13:14 - | -LL | pub fn is_transmutable<Src, Dst, Context>() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs deleted file mode 100644 index 662c32af1..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_tricky_unreachable_field.rs +++ /dev/null @@ -1,51 +0,0 @@ -// check-pass -//! NOTE: This test documents a known-bug in the implementation of the -//! transmutability trait. Once fixed, the above "check-pass" header should be -//! removed, and an "ERROR cannot be safely transmuted" annotation should be added at the end -//! of the line starting with `assert::is_transmutable`. -//! -//! Unless visibility is assumed, a transmutation should be rejected 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 -//! forbid naming such types.) -//! -//! This test exercises a tricky-to-implement instance of this principle: the -//! "pub-in-priv trick". In the below example, the type `dst::private::Zst` is -//! unreachable from `Context`. Consequently, the transmute from `Src` to `Dst` -//! SHOULD be rejected. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - mod private { - #[repr(C)] pub struct Zst; // <- unreachable type - } - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: private::Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); -} diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs deleted file mode 100644 index d7e21676f..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected 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 -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(self) struct Zst; // <- unreachable type - - #[repr(C)] pub(in super) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); //~ ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr deleted file mode 100644 index 4e648664d..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_unreachable_field.rs:37:41 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_unreachable_field.rs:15:14 - | -LL | pub fn is_transmutable<Src, Dst, Context>() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs deleted file mode 100644 index c7b59f15b..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Unless visibility is assumed, a transmutation should be rejected 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 -//! forbid naming such types.) - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code)] - -mod assert { - use std::mem::BikeshedIntrinsicFrom; - - pub fn is_transmutable<Src, Dst, Context>() - where - Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - {} -} - -mod src { - #[repr(C)] pub(in super) struct Zst; - - #[repr(C)] pub(in super) struct Src { - pub(in super) field: Zst, - } -} - -mod dst { - #[repr(C)] pub(in super) struct Zst; - - // unreachable type - #[repr(C)] pub(self) struct Dst { - pub(in super) field: Zst, - } -} - -fn test() { - struct Context; - assert::is_transmutable::<src::Src, dst::Dst, Context>(); - //~^ ERROR `Dst` is private - //~| ERROR cannot be safely transmuted -} diff --git a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr b/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr deleted file mode 100644 index bd72d64cc..000000000 --- a/src/test/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0603]: struct `Dst` is private - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:46 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^ private struct - | -note: the struct `Dst` is defined here - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:31:16 - | -LL | #[repr(C)] pub(self) struct Dst { - | ^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:41 - | -LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. - | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` -note: required by a bound in `is_transmutable` - --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:15:14 - | -LL | pub fn is_transmutable<Src, Dst, Context>() - | --------------- required by a bound in this -LL | where -LL | Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0603. -For more information about an error, try `rustc --explain E0277`. |