diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:12:43 +0000 |
commit | cf94bdc0742c13e2a0cac864c478b8626b266e1b (patch) | |
tree | 044670aa50cc5e2b4229aa0b6b3df6676730c0a6 /src/test/ui/transmute | |
parent | Adding debian version 1.65.0+dfsg1-2. (diff) | |
download | rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.tar.xz rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/transmute-equal-assoc-types.rs | 4 | ||||
-rw-r--r-- | src/test/ui/transmute-equal-assoc-types.stderr | 11 | ||||
-rw-r--r-- | src/test/ui/transmute/lifetimes.rs | 23 | ||||
-rw-r--r-- | src/test/ui/transmute/main.rs | 2 | ||||
-rw-r--r-- | src/test/ui/transmute/main.stderr | 10 |
5 files changed, 28 insertions, 22 deletions
diff --git a/src/test/ui/transmute-equal-assoc-types.rs b/src/test/ui/transmute-equal-assoc-types.rs index 6f357543e..d1b593b7f 100644 --- a/src/test/ui/transmute-equal-assoc-types.rs +++ b/src/test/ui/transmute-equal-assoc-types.rs @@ -1,9 +1,11 @@ +// check-pass + trait Foo { type Bar; } unsafe fn noop<F: Foo>(foo: F::Bar) -> F::Bar { - ::std::mem::transmute(foo) //~ ERROR cannot transmute between types of different sizes + ::std::mem::transmute(foo) } fn main() {} diff --git a/src/test/ui/transmute-equal-assoc-types.stderr b/src/test/ui/transmute-equal-assoc-types.stderr deleted file mode 100644 index ce7657f96..000000000 --- a/src/test/ui/transmute-equal-assoc-types.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-equal-assoc-types.rs:6:5 - | -LL | ::std::mem::transmute(foo) - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `<F as Foo>::Bar` does not have a fixed size - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/transmute/lifetimes.rs b/src/test/ui/transmute/lifetimes.rs new file mode 100644 index 000000000..943191551 --- /dev/null +++ b/src/test/ui/transmute/lifetimes.rs @@ -0,0 +1,23 @@ +// check-pass + +use std::ptr::NonNull; + +struct Foo<'a, T: ?Sized>(&'a (), NonNull<T>); + +fn foo<'a, 'b, T: ?Sized>(x: Foo<'a, T>) -> Foo<'b, T> { + unsafe { std::mem::transmute(x) } +} + +struct Bar<'a, T: ?Sized>(&'a T); + +fn bar<'a, 'b, T: ?Sized>(x: Bar<'a, T>) -> Bar<'b, T> { + unsafe { std::mem::transmute(x) } +} + +struct Boo<'a, T: ?Sized>(&'a T, u32); + +fn boo<'a, 'b, T: ?Sized>(x: Boo<'a, T>) -> Boo<'b, T> { + unsafe { std::mem::transmute(x) } +} + +fn main() {} diff --git a/src/test/ui/transmute/main.rs b/src/test/ui/transmute/main.rs index cb46fc5ec..da4a0a660 100644 --- a/src/test/ui/transmute/main.rs +++ b/src/test/ui/transmute/main.rs @@ -10,7 +10,7 @@ pub trait TypeConstructor<'a> { unsafe fn transmute_lifetime<'a, 'b, C>(x: <C as TypeConstructor<'a>>::T) -> <C as TypeConstructor<'b>>::T where for<'z> C: TypeConstructor<'z> { - transmute(x) //~ ERROR cannot transmute between types of different sizes + transmute(x) } unsafe fn sizes() { diff --git a/src/test/ui/transmute/main.stderr b/src/test/ui/transmute/main.stderr index f48562094..6cb0d7f67 100644 --- a/src/test/ui/transmute/main.stderr +++ b/src/test/ui/transmute/main.stderr @@ -1,12 +1,4 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/main.rs:13:5 - | -LL | transmute(x) - | ^^^^^^^^^ - | - = note: `<C as TypeConstructor>::T` does not have a fixed size - -error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> $DIR/main.rs:17:17 | LL | let x: u8 = transmute(10u16); @@ -33,6 +25,6 @@ LL | let x: Foo = transmute(10); = note: source type: `i32` (32 bits) = note: target type: `Foo` (0 bits) -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0512`. |