Closed
Description
#![feature(const_generics)]
fn take_const_param<const N: usize>() {
match 1 {
N => {},
_ => {},
}
}
fn main() {
take_const_param::<0>();
take_const_param::<1>()
}
results in:
warning: unreachable pattern
--> src/main.rs:6:9
|
5 | N => {},
| - matches any value
6 | _ => {},
| ^ unreachable pattern
|
= note: `#[warn(unreachable_patterns)]` on by default
warning: unused variable: `N`
--> src/main.rs:5:9
|
5 | N => {},
| ^ help: consider prefixing with an underscore: `_N`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable `N` should have a snake case name
--> src/main.rs:5:9
|
5 | N => {},
| ^ help: convert the identifier to snake case: `n`
|
= note: `#[warn(non_snake_case)]` on by default
Finished dev [unoptimized + debuginfo] target(s) in 0.64s
Running `target/debug/playground`
but should, similarly to associated constants, result in:
error[E0158]: const parameters cannot be referenced in patterns
--> src/lib.rs:L:C
|
L | N => {}
| ^