From c098322b27133cbcfb93485a10750a39dea6154a 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 | 3 +-- tests/test_pat.rs | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/pat.rs b/src/pat.rs index c029bae83..793a1c007 100644 --- a/src/pat.rs +++ b/src/pat.rs @@ -242,7 +242,6 @@ pub(crate) mod parsing { use crate::expr::{ Expr, ExprConst, ExprLit, ExprMacro, ExprPath, ExprRange, Member, RangeLimits, }; - use crate::ext::IdentExt as _; use crate::ident::Ident; use crate::lit::Lit; use crate::mac::{self, Macro}; @@ -470,7 +469,7 @@ pub(crate) mod parsing { attrs: Vec::new(), by_ref: input.parse()?, mutability: input.parse()?, - ident: input.call(Ident::parse_any)?, + ident: input.parse()?, subpat: { if input.peek(Token![@]) { let at_token: Token![@] = input.parse()?; diff --git a/tests/test_pat.rs b/tests/test_pat.rs index 3d13385fd..2231656f7 100644 --- a/tests/test_pat.rs +++ b/tests/test_pat.rs @@ -9,14 +9,6 @@ use syn::parse::Parser; use syn::punctuated::Punctuated; use syn::{parse_quote, token, Item, Pat, PatTuple, Stmt, Token}; -#[test] -fn test_pat_ident() { - match Pat::parse_single.parse2(quote!(self)).unwrap() { - Pat::Ident(_) => (), - value => panic!("expected PatIdent, got {:?}", value), - } -} - #[test] fn test_pat_path() { match Pat::parse_single.parse2(quote!(self::CONST)).unwrap() {