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