Add test forbidding const parameters in const fn
This commit is contained in:
parent
455d659e91
commit
2f73245ca4
2 changed files with 36 additions and 0 deletions
12
src/test/ui/const-generics/const-fn-with-const-param.rs
Normal file
12
src/test/ui/const-generics/const-fn-with-const-param.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
const fn const_u32_identity<const X: u32>() -> u32 {
|
||||
//~^ ERROR const parameters are not permitted in `const fn`
|
||||
//~^^ ERROR const generics in any position are currently unsupported
|
||||
X
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", const_u32_identity::<18>());
|
||||
}
|
||||
24
src/test/ui/const-generics/const-fn-with-const-param.stderr
Normal file
24
src/test/ui/const-generics/const-fn-with-const-param.stderr
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/const-fn-with-const-param.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: const parameters are not permitted in `const fn`
|
||||
--> $DIR/const-fn-with-const-param.rs:4:1
|
||||
|
|
||||
LL | / const fn const_u32_identity<const X: u32>() -> u32 {
|
||||
LL | | //~^ ERROR const parameters are not permitted in `const fn`
|
||||
LL | | //~^^ ERROR const generics in any position are currently unsupported
|
||||
LL | | X
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: const generics in any position are currently unsupported
|
||||
--> $DIR/const-fn-with-const-param.rs:4:35
|
||||
|
|
||||
LL | const fn const_u32_identity<const X: u32>() -> u32 {
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue