From 348a0e7c201da6a630e1dfbc10f6746fc5bc89a2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 17 Apr 2024 22:47:37 -0700 Subject: [PATCH] Require ident in PatIdent to be a legal binding name --- src/pat.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pat.rs b/src/pat.rs index c029bae83..98502d0ba 100644 --- a/src/pat.rs +++ b/src/pat.rs @@ -470,7 +470,13 @@ pub(crate) mod parsing { attrs: Vec::new(), by_ref: input.parse()?, mutability: input.parse()?, - ident: input.call(Ident::parse_any)?, + ident: { + if input.peek(Token![self]) { + input.call(Ident::parse_any)? + } else { + input.parse()? + } + }, subpat: { if input.peek(Token![@]) { let at_token: Token![@] = input.parse()?;