2018-08-10 16:46:59 -05:00
|
|
|
// normalize-stderr-test "\d+ bits" -> "N bits"
|
|
|
|
|
2014-12-22 19:57:14 -06:00
|
|
|
// Tests that are conservative around thin/fat pointer mismatches.
|
|
|
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
use std::mem::transmute;
|
|
|
|
|
2015-01-05 15:16:49 -06:00
|
|
|
struct Foo<T: ?Sized> {
|
2014-12-22 19:57:14 -06:00
|
|
|
t: Box<T>
|
|
|
|
}
|
|
|
|
|
2015-01-05 15:16:49 -06:00
|
|
|
impl<T: ?Sized> Foo<T> {
|
2015-01-08 04:54:35 -06:00
|
|
|
fn m(x: &T) -> &isize where T : Sized {
|
2014-12-22 19:57:14 -06:00
|
|
|
// OK here, because T : Sized is in scope.
|
|
|
|
unsafe { transmute(x) }
|
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn n(x: &T) -> &isize {
|
2014-12-22 19:57:14 -06:00
|
|
|
// Not OK here, because T : Sized is not in scope.
|
2017-05-29 18:22:41 -05:00
|
|
|
unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes
|
2014-12-22 19:57:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|