]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/locals-in-const-fn.rs
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
[rust.git] / tests / ui / consts / locals-in-const-fn.rs
1 // run-pass
2
3 // https://github.com/rust-lang/rust/issues/48821
4
5 const fn foo(i: usize) -> usize {
6     let x = i;
7     x
8 }
9
10 static FOO: usize = foo(42);
11
12 const fn bar(mut i: usize) -> usize {
13     i += 8;
14     let x = &i;
15     *x
16 }
17
18 static BAR: usize = bar(42);
19
20 const fn boo(mut i: usize) -> usize {
21     {
22         let mut x = i;
23         x += 10;
24         i = x;
25     }
26     i
27 }
28
29 static BOO: usize = boo(42);
30
31 fn main() {
32     assert!(FOO == 42);
33     assert!(BAR == 50);
34     assert!(BOO == 52);
35 }