From 72c1568f961738db52a9592beef26035f2a28c3d Mon Sep 17 00:00:00 2001 From: Yukang Date: Sun, 5 Jul 2026 14:31:45 +0800 Subject: [PATCH] Accept `..=` as a pattern start in macros --- compiler/rustc_ast/src/token.rs | 1 + tests/ui/macros/range-to-inclusive-pat-issue-120737.rs | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/ui/macros/range-to-inclusive-pat-issue-120737.rs diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index e1746039963f4..8ead6c66e9829 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -712,6 +712,7 @@ impl Token { Literal(_) | // literal DotDot | // range pattern (future compat) DotDotDot | // range pattern (future compat) + DotDotEq | // range-to-inclusive pattern PathSep | // path Lt | // path (UFCS constant) Shl => true, // path (double UFCS) diff --git a/tests/ui/macros/range-to-inclusive-pat-issue-120737.rs b/tests/ui/macros/range-to-inclusive-pat-issue-120737.rs new file mode 100644 index 0000000000000..0bd04b66d57ca --- /dev/null +++ b/tests/ui/macros/range-to-inclusive-pat-issue-120737.rs @@ -0,0 +1,8 @@ +//@ check-pass + +// Ensure macro `:pat` fragments accept `..=` as a valid pattern start. + +fn main() { + assert!(matches!(2, ..=0 | 2)); + assert!(matches!(0, ..=0)); +}