Skip to content

Commit f3e1b96

Browse files
committed
Add test that min const fns can't call unstable min const fns even with the feature gate active
1 parent d125e90 commit f3e1b96

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Diff for: src/test/ui/consts/min_const_fn/min_const_fn_libstd_stability.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
we're apparently really bad at it",
1414
issue = "0")]
1515

16-
#![feature(rustc_const_unstable, const_fn, foo)]
16+
#![feature(rustc_const_unstable, const_fn, foo, foo2)]
1717
#![feature(staged_api)]
1818

1919
#[stable(feature = "rust1", since = "1.0.0")]
@@ -35,4 +35,12 @@ const fn bar2() -> u32 { foo2() } //~ ERROR can only call other `min_const_fn`
3535
// conformity is required, even with `const_fn` feature gate
3636
const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
3737

38+
// check whether this function cannot be called even with the feature gate active
39+
#[unstable(feature = "foo2", issue="0")]
40+
const fn foo2_gated() -> u32 { 42 }
41+
42+
#[stable(feature = "rust1", since = "1.0.0")]
43+
// can't call non-min_const_fn
44+
const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `min_const_fn`
45+
3846
fn main() {}

Diff for: src/test/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ error: only int, `bool` and `char` operations are stable in const fn
1616
LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 } //~ ERROR only int, `bool` and `char` operations
1717
| ^^^^^^^^^^^^^
1818

19-
error: aborting due to 3 previous errors
19+
error: can only call other `min_const_fn` within a `min_const_fn`
20+
--> $DIR/min_const_fn_libstd_stability.rs:44:32
21+
|
22+
LL | const fn bar2_gated() -> u32 { foo2_gated() } //~ ERROR can only call other `min_const_fn`
23+
| ^^^^^^^^^^^^
24+
25+
error: aborting due to 4 previous errors
2026

0 commit comments

Comments
 (0)