]> git.lizzy.rs Git - rust.git/blob - src/test/ui/transmute/main.rs
Rollup merge of #103757 - ffmancera:ff/clarify_E0207, r=jackh726
[rust.git] / src / test / ui / transmute / main.rs
1 // normalize-stderr-32bit: "`&str` \(64 bits\)" -> "`&str` ($$STR bits)"
2 // normalize-stderr-64bit: "`&str` \(128 bits\)" -> "`&str` ($$STR bits)"
3
4 use std::mem::transmute;
5
6 pub trait TypeConstructor<'a> {
7     type T;
8 }
9
10 unsafe fn transmute_lifetime<'a, 'b, C>(x: <C as TypeConstructor<'a>>::T)
11                                         -> <C as TypeConstructor<'b>>::T
12 where for<'z> C: TypeConstructor<'z> {
13     transmute(x)
14 }
15
16 unsafe fn sizes() {
17     let x: u8 = transmute(10u16); //~ ERROR cannot transmute between types of different sizes
18 }
19
20 unsafe fn ptrs() {
21     let x: u8 = transmute("test"); //~ ERROR cannot transmute between types of different sizes
22 }
23
24 union Foo { x: () }
25 unsafe fn vary() {
26     let x: Foo = transmute(10); //~ ERROR cannot transmute between types of different sizes
27 }
28
29 fn main() {}