]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-fn-not-safe-for-const.rs
Do not suggest `let_else` if no bindings would be introduced
[rust.git] / src / test / ui / consts / const-fn-not-safe-for-const.rs
1 // Test that we can't call random fns in a const fn or do other bad things.
2
3 use std::mem::transmute;
4
5 fn random() -> u32 {
6     0
7 }
8
9 const fn sub(x: &u32) -> usize {
10     unsafe { transmute(x) }
11 }
12
13 const fn sub1() -> u32 {
14     random() //~ ERROR E0015
15 }
16
17 static Y: u32 = 0;
18
19 const fn get_Y() -> u32 {
20     Y
21     //~^ ERROR E0013
22 }
23
24 const fn get_Y_addr() -> &'static u32 {
25     &Y
26     //~^ ERROR E0013
27 }
28
29 const fn get() -> u32 {
30     let x = 22;
31     let y = 44;
32     x + y
33 }
34
35 fn main() {}