2015-05-05 12:47:04 +00: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 07:31:27 +00:00
|
|
|
fn random() -> u32 {
|
|
|
|
0
|
|
|
|
}
|
2015-05-05 12:47:04 +00:00
|
|
|
|
|
|
|
const fn sub(x: &u32) -> usize {
|
2018-08-20 18:51:48 +00:00
|
|
|
unsafe { transmute(x) }
|
2015-05-05 12:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const fn sub1() -> u32 {
|
|
|
|
random() //~ ERROR E0015
|
|
|
|
}
|
|
|
|
|
|
|
|
static Y: u32 = 0;
|
|
|
|
|
|
|
|
const fn get_Y() -> u32 {
|
|
|
|
Y
|
2021-06-03 07:31:27 +00:00
|
|
|
//~^ ERROR E0013
|
2015-05-05 12:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const fn get_Y_addr() -> &'static u32 {
|
|
|
|
&Y
|
2021-06-03 07:31:27 +00:00
|
|
|
//~^ ERROR E0013
|
2015-05-05 12:47:04 +00:00
|
|
|
}
|
|
|
|
|
2016-05-02 22:57:35 +00:00
|
|
|
const fn get() -> u32 {
|
2018-12-28 19:05:22 +00:00
|
|
|
let x = 22;
|
|
|
|
let y = 44;
|
2016-05-02 22:57:35 +00:00
|
|
|
x + y
|
|
|
|
}
|
|
|
|
|
2018-05-29 00:38:18 +00:00
|
|
|
fn main() {}
|