]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.rs
7faba480a233e0b36ffcd2b858cf92e68bcedc70
[rust.git] / src / test / ui / consts / min_const_fn / min_const_unsafe_fn_libstd_stability.rs
1 #![unstable(feature = "humans",
2             reason = "who ever let humans program computers,
3             we're apparently really bad at it",
4             issue = "0")]
5
6 #![feature(rustc_const_unstable, const_fn, foo, foo2)]
7 #![feature(staged_api)]
8
9 #[stable(feature = "rust1", since = "1.0.0")]
10 #[rustc_const_unstable(feature="foo")]
11 const unsafe fn foo() -> u32 { 42 }
12
13 #[stable(feature = "rust1", since = "1.0.0")]
14 // can't call non-min_const_fn
15 const unsafe fn bar() -> u32 { unsafe { foo() } } //~ ERROR can only call other `min_const_fn`
16
17 #[unstable(feature = "rust1", issue="0")]
18 const unsafe fn foo2() -> u32 { 42 }
19
20 #[stable(feature = "rust1", since = "1.0.0")]
21 // can't call non-min_const_fn
22 const unsafe fn bar2() -> u32 { unsafe { foo2() } } //~ ERROR can only call other `min_const_fn`
23
24 #[stable(feature = "rust1", since = "1.0.0")]
25 // conformity is required, even with `const_fn` feature gate
26 const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` op
27
28 // check whether this function cannot be called even with the feature gate active
29 #[unstable(feature = "foo2", issue="0")]
30 const unsafe fn foo2_gated() -> u32 { 42 }
31
32 #[stable(feature = "rust1", since = "1.0.0")]
33 // can't call non-min_const_fn
34 const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } } //~ ERROR can only call other
35
36 fn main() {}