2024-06-21 15:15:36 +10:00
|
|
|
//@ normalize-stderr-test: "\d+ bits" -> "N bits"
|
2018-08-10 22:46:59 +01:00
|
|
|
|
2014-12-22 20:57:14 -05:00
|
|
|
// Tests that are conservative around thin/fat pointer mismatches.
|
|
|
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
use std::mem::transmute;
|
|
|
|
|
2015-01-06 10:16:49 +13:00
|
|
|
fn a<T, U: ?Sized>(x: &[T]) -> &U {
|
2018-12-21 14:15:47 +00:00
|
|
|
unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
|
2014-12-22 20:57:14 -05:00
|
|
|
}
|
|
|
|
|
2015-01-06 10:16:49 +13:00
|
|
|
fn b<T: ?Sized, U: ?Sized>(x: &T) -> &U {
|
2018-12-21 14:15:47 +00:00
|
|
|
unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
|
2014-12-22 20:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn c<T, U>(x: &T) -> &U {
|
|
|
|
unsafe { transmute(x) }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn d<T, U>(x: &[T]) -> &[U] {
|
|
|
|
unsafe { transmute(x) }
|
|
|
|
}
|
|
|
|
|
2015-01-06 10:16:49 +13:00
|
|
|
fn e<T: ?Sized, U>(x: &T) -> &U {
|
2018-12-21 14:15:47 +00:00
|
|
|
unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
|
2014-12-22 20:57:14 -05:00
|
|
|
}
|
|
|
|
|
2015-01-06 10:16:49 +13:00
|
|
|
fn f<T, U: ?Sized>(x: &T) -> &U {
|
2018-12-21 14:15:47 +00:00
|
|
|
unsafe { transmute(x) } //~ ERROR cannot transmute between types of different sizes
|
2014-12-22 20:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|