Add test that min const fns can't call unstable min const fns even with the feature gate active
This commit is contained in:
parent
d125e904b5
commit
f3e1b968e3
@ -13,7 +13,7 @@
|
||||
we're apparently really bad at it",
|
||||
issue = "0")]
|
||||
|
||||
#![feature(rustc_const_unstable, const_fn, foo)]
|
||||
#![feature(rustc_const_unstable, const_fn, foo, foo2)]
|
||||
#![feature(staged_api)]
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -35,4 +35,12 @@ const fn bar2() -> u32 { foo2() } //~ ERROR can only call other `min_const_fn`
|
||||
// conformity is required, even with `const_fn` feature gate
|
||||
const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
|
||||
|
||||
// check whether this function cannot be called even with the feature gate active
|
||||
#[unstable(feature = "foo2", issue="0")]
|
||||
const fn foo2_gated() -> u32 { 42 }
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
// can't call non-min_const_fn
|
||||
const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `min_const_fn`
|
||||
|
||||
fn main() {}
|
||||
|
@ -16,5 +16,11 @@ error: only int, `bool` and `char` operations are stable in const fn
|
||||
LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: can only call other `min_const_fn` within a `min_const_fn`
|
||||
--> $DIR/min_const_fn_libstd_stability.rs:44:32
|
||||
|
|
||||
LL | const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `min_const_fn`
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user