]> git.lizzy.rs Git - rust.git/blob - src/test/ui/transmute/transmute-impl.rs
Rollup merge of #103989 - arlosi:arm32-panic, r=Amanieu
[rust.git] / src / test / ui / transmute / transmute-impl.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 struct Foo<T: ?Sized> {
10     t: Box<T>
11 }
12
13 impl<T: ?Sized> Foo<T> {
14     fn m(x: &T) -> &isize where T : Sized {
15         // OK here, because T : Sized is in scope.
16         unsafe { transmute(x) }
17     }
18
19     fn n(x: &T) -> &isize {
20         // Not OK here, because T : Sized is not in scope.
21         unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
22     }
23 }
24
25 fn main() { }