]> git.lizzy.rs Git - rust.git/blob - src/test/ui/inline-const/const-match-pat-generic.rs
Rollup merge of #93813 - xldenis:public-mir-passes, r=wesleywiser
[rust.git] / src / test / ui / inline-const / const-match-pat-generic.rs
1 #![allow(incomplete_features)]
2 #![feature(inline_const_pat)]
3 #![feature(generic_const_exprs)]
4
5 // rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter
6
7 fn foo<const V: usize>() {
8     match 0 {
9         const { V } => {},
10         //~^ ERROR const parameters cannot be referenced in patterns [E0158]
11         _ => {},
12     }
13 }
14
15 const fn f(x: usize) -> usize {
16     x + 1
17 }
18
19 fn bar<const V: usize>() where [(); f(V)]: {
20     match 0 {
21         const { f(V) } => {},
22         //~^ ERROR constant pattern depends on a generic parameter
23         //~| ERROR constant pattern depends on a generic parameter
24         _ => {},
25     }
26 }
27
28 fn main() {
29     foo::<1>();
30     bar::<1>();
31 }