diff options
| author | Gary Guo <gary@garyguo.net> | 2021-08-14 21:56:57 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2021-08-15 18:17:21 +0100 |
| commit | e62ecdc5a7cbd44a9ade5061ddad4d8a4e1d6599 (patch) | |
| tree | ca83c26048faffc98c1f946f84a6979575728a76 /src | |
| parent | 2969aece415baa1a42df2a06ba635311000a2b5b (diff) | |
| download | rust-e62ecdc5a7cbd44a9ade5061ddad4d8a4e1d6599.tar.gz rust-e62ecdc5a7cbd44a9ade5061ddad4d8a4e1d6599.zip | |
Add a dead code test for using anon const in pattern
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/lint/dead-code/anon-const-in-pat.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/lint/dead-code/anon-const-in-pat.rs b/src/test/ui/lint/dead-code/anon-const-in-pat.rs new file mode 100644 index 00000000000..4c6211a279a --- /dev/null +++ b/src/test/ui/lint/dead-code/anon-const-in-pat.rs @@ -0,0 +1,45 @@ +// check-pass +#![feature(inline_const)] +#![allow(incomplete_features)] +#![deny(dead_code)] + +const fn one() -> i32 { + 1 +} + +const fn two() -> i32 { + 2 +} + +const fn three() -> i32 { + 3 +} + +fn inline_const() { + // rust-lang/rust#78171: dead_code lint triggers even though function is used in const pattern + match 1 { + const { one() } => {} + _ => {} + } +} + +fn inline_const_range() { + match 1 { + 1 ..= const { two() } => {} + _ => {} + } +} + +struct S<const C: i32>; + +fn const_generic_arg() { + match S::<3> { + S::<{three()}> => {} + } +} + +fn main() { + inline_const(); + inline_const_range(); + const_generic_arg(); +} |
