]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 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. | |
4 | // | |
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. | |
10 | ||
11 | // Tests that are conservative around thin/fat pointer mismatches. | |
12 | ||
13 | #![allow(dead_code)] | |
14 | ||
15 | use std::mem::transmute; | |
16 | ||
17 | struct Foo<T: ?Sized> { | |
18 | t: Box<T> | |
19 | } | |
20 | ||
21 | impl<T: ?Sized> Foo<T> { | |
22 | fn m(x: &T) -> &isize where T : Sized { | |
23 | // OK here, because T : Sized is in scope. | |
24 | unsafe { transmute(x) } | |
25 | } | |
26 | ||
27 | fn n(x: &T) -> &isize { | |
28 | // Not OK here, because T : Sized is not in scope. | |
b039eaaf | 29 | unsafe { transmute(x) } //~ ERROR transmute called with differently sized types |
1a4d82fc JJ |
30 | } |
31 | } | |
32 | ||
33 | fn main() { } |