From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/transmute/transmute-fat-pointers.rs | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/ui/transmute/transmute-fat-pointers.rs (limited to 'src/test/ui/transmute/transmute-fat-pointers.rs') diff --git a/src/test/ui/transmute/transmute-fat-pointers.rs b/src/test/ui/transmute/transmute-fat-pointers.rs new file mode 100644 index 000000000..7c1beffd1 --- /dev/null +++ b/src/test/ui/transmute/transmute-fat-pointers.rs @@ -0,0 +1,33 @@ +// normalize-stderr-test "\d+ bits" -> "N bits" + +// Tests that are conservative around thin/fat pointer mismatches. + +#![allow(dead_code)] + +use std::mem::transmute; + +fn a(x: &[T]) -> &U { + unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes +} + +fn b(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes +} + +fn c(x: &T) -> &U { + unsafe { transmute(x) } +} + +fn d(x: &[T]) -> &[U] { + unsafe { transmute(x) } +} + +fn e(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes +} + +fn f(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes +} + +fn main() { } -- cgit v1.2.3