2015-05-05 08:47:04 -04:00
|
|
|
// Test that we can't call random fns in a const fn or do other bad things.
|
|
|
|
|
|
|
|
use std::mem::transmute;
|
|
|
|
|
2021-06-03 03:31:27 -04:00
|
|
|
fn random() -> u32 {
|
|
|
|
0
|
|
|
|
}
|
2015-05-05 08:47:04 -04:00
|
|
|
|
|
|
|
const fn sub(x: &u32) -> usize {
|
2018-08-20 19:51:48 +01:00
|
|
|
unsafe { transmute(x) }
|
2015-05-05 08:47:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const fn sub1() -> u32 {
|
|
|
|
random() //~ ERROR E0015
|
|
|
|
}
|
|
|
|
|
|
|
|
static Y: u32 = 0;
|
|
|
|
|
|
|
|
const fn get_Y() -> u32 {
|
|
|
|
Y
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn get_Y_addr() -> &'static u32 {
|
|
|
|
&Y
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:57:35 +03:00
|
|
|
const fn get() -> u32 {
|
2018-12-28 20:05:22 +01:00
|
|
|
let x = 22;
|
|
|
|
let y = 44;
|
2016-05-03 01:57:35 +03:00
|
|
|
x + y
|
|
|
|
}
|
|
|
|
|
2018-05-29 01:38:18 +01:00
|
|
|
fn main() {}
|