]> git.lizzy.rs Git - rust.git/blob - src/test/ui/transmute/transmute-fat-pointers.rs
Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyup
[rust.git] / src / test / ui / transmute / transmute-fat-pointers.rs
1 // normalize-stderr-test "\d+ bits" -> "N bits"
2
3 // Tests that are conservative around thin/fat pointer mismatches.
4
5 #![allow(dead_code)]
6
7 use std::mem::transmute;
8
9 fn a<T, U: ?Sized>(x: &[T]) -> &U {
10     unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
11 }
12
13 fn b<T: ?Sized, U: ?Sized>(x: &T) -> &U {
14     unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
15 }
16
17 fn c<T, U>(x: &T) -> &U {
18     unsafe { transmute(x) }
19 }
20
21 fn d<T, U>(x: &[T]) -> &[U] {
22     unsafe { transmute(x) }
23 }
24
25 fn e<T: ?Sized, U>(x: &T) -> &U {
26     unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
27 }
28
29 fn f<T, U: ?Sized>(x: &T) -> &U {
30     unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
31 }
32
33 fn main() { }