]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.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 = "none")]
5
6 #![feature(const_fn, const_fn_floating_point_arithmetic, foo, foo2)]
7 #![feature(staged_api)]
8
9 #[stable(feature = "rust1", since = "1.0.0")]
10 #[rustc_const_unstable(feature="foo", issue = "none")]
11 const unsafe fn foo() -> u32 { 42 }
12
13 #[stable(feature = "rust1", since = "1.0.0")]
14 #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
15 // can't call non-min_const_fn
16 const unsafe fn bar() -> u32 { unsafe { foo() } } //~ ERROR not yet stable as a const fn
17
18 #[unstable(feature = "rust1", issue = "none")]
19 const unsafe fn foo2() -> u32 { 42 }
20
21 #[stable(feature = "rust1", since = "1.0.0")]
22 #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
23 // can't call non-min_const_fn
24 const unsafe fn bar2() -> u32 { unsafe { foo2() } } //~ ERROR not yet stable as a const fn
25
26 #[stable(feature = "rust1", since = "1.0.0")]
27 #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
28 // conformity is required, even with `const_fn` feature gate
29 const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 }
30 //~^ ERROR const-stable function cannot use `#[feature(const_fn_floating_point_arithmetic)]`
31
32 // check whether this function cannot be called even with the feature gate active
33 #[unstable(feature = "foo2", issue = "none")]
34 const unsafe fn foo2_gated() -> u32 { 42 }
35
36 #[stable(feature = "rust1", since = "1.0.0")]
37 #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
38 // can't call non-min_const_fn
39 const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } }
40 //~^ ERROR not yet stable as a const fn
41
42 fn main() {}