rust/src/test/ui/const-generics/const-expression-parameter.rs

26 lines
449 B
Rust
Raw Normal View History

// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
2019-02-07 09:10:11 +00:00
fn i32_identity<const X: i32>() -> i32 {
2019-02-07 09:10:11 +00:00
5
}
fn foo_a() {
i32_identity::<-1>(); // ok
2019-02-07 09:10:11 +00:00
}
fn foo_b() {
i32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
2019-02-07 09:10:11 +00:00
}
fn foo_c() {
i32_identity::< -1 >(); // ok
}
2019-02-07 09:10:11 +00:00
fn main() {
i32_identity::<5>(); // ok
2019-02-07 09:10:11 +00:00
}