From fdccb42167028b33a7ceee7343cfe3500c1c4b8b Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 22 May 2025 12:52:46 +0100 Subject: Add test/comment about const patterns with unused params --- tests/ui/pattern/unused-parameters-const-pattern.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/ui/pattern/unused-parameters-const-pattern.rs (limited to 'tests/ui/pattern') diff --git a/tests/ui/pattern/unused-parameters-const-pattern.rs b/tests/ui/pattern/unused-parameters-const-pattern.rs new file mode 100644 index 00000000000..107c65ddfd3 --- /dev/null +++ b/tests/ui/pattern/unused-parameters-const-pattern.rs @@ -0,0 +1,19 @@ +//@ check-pass + +// Tests that const patterns that use generic parameters are +// allowed if we are still able to evaluate them. + +trait Trait { const ASSOC: usize; } + +impl Trait for T { + const ASSOC: usize = 10; +} + +fn foo(a: usize) { + match a { + ::ASSOC => (), + _ => (), + } +} + +fn main() {} -- cgit 1.4.1-3-g733a5