Skip to content

Commit

Permalink
Add test that min const fns can't call unstable min const fns even wi…
Browse files Browse the repository at this point in the history
…th the feature gate active
  • Loading branch information
oli-obk committed Aug 31, 2018
1 parent d125e90 commit f3e1b96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Expand Up @@ -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")]
Expand All @@ -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() {}
Expand Up @@ -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

0 comments on commit f3e1b96

Please sign in to comment.