1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
16 // Tests that `transmute` cannot be called on type parameters.
18 use std::mem::transmute;
20 unsafe fn f<T>(x: T) {
21 let _: i32 = transmute(x);
22 //~^ ERROR transmute called with types of different sizes
25 unsafe fn g<T>(x: (T, i32)) {
26 let _: i32 = transmute(x);
27 //~^ ERROR transmute called with types of different sizes
30 unsafe fn h<T>(x: [T; 10]) {
31 let _: i32 = transmute(x);
32 //~^ ERROR transmute called with types of different sizes
39 unsafe fn i<T>(x: Bad<T>) {
40 let _: i32 = transmute(x);
41 //~^ ERROR transmute called with types of different sizes
49 unsafe fn j<T>(x: Worse<T>) {
50 let _: i32 = transmute(x);
51 //~^ ERROR transmute called with types of different sizes
54 unsafe fn k<T>(x: Option<T>) {
55 let _: i32 = transmute(x);
56 //~^ ERROR transmute called with types of different sizes