• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // check-pass
2 #![feature(inline_const_pat)]
3 #![allow(incomplete_features)]
4 #![deny(dead_code)]
5 
one() -> i326 const fn one() -> i32 {
7     1
8 }
9 
two() -> i3210 const fn two() -> i32 {
11     2
12 }
13 
three() -> i3214 const fn three() -> i32 {
15     3
16 }
17 
inline_const()18 fn inline_const() {
19     // rust-lang/rust#78171: dead_code lint triggers even though function is used in const pattern
20     match 1 {
21         const { one() } => {}
22         _ => {}
23     }
24 }
25 
inline_const_range()26 fn inline_const_range() {
27     match 1 {
28         1 ..= const { two() } => {}
29         _ => {}
30     }
31 }
32 
33 struct S<const C: i32>;
34 
const_generic_arg()35 fn const_generic_arg() {
36     match S::<3> {
37         S::<{three()}> => {}
38     }
39 }
40 
main()41 fn main() {
42     inline_const();
43     inline_const_range();
44     const_generic_arg();
45 }
46