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

23 lines
440 B
Rust
Raw Normal View History

2019-02-07 09:10:11 +00:00
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
fn i32_identity<const X: i32>() -> i32 {
2019-02-07 09:10:11 +00:00
5
}
fn foo_a() {
i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
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
}