From af4148970a800b8df733f961b14403b800d3fb01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sat, 20 Feb 2021 12:36:17 +0200 Subject: Fix incorrect missing field diagnostic with box patterns --- crates/syntax/src/ast/node_ext.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 2fa7b8c1e..52ac97c84 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -381,11 +381,20 @@ impl ast::RecordPatField { if let Some(name_ref) = self.name_ref() { return Some(NameOrNameRef::NameRef(name_ref)); } - if let Some(ast::Pat::IdentPat(pat)) = self.pat() { - let name = pat.name()?; - return Some(NameOrNameRef::Name(name)); + match self.pat() { + Some(ast::Pat::IdentPat(pat)) => { + let name = pat.name()?; + Some(NameOrNameRef::Name(name)) + } + Some(ast::Pat::BoxPat(pat)) => match pat.pat() { + Some(ast::Pat::IdentPat(pat)) => { + let name = pat.name()?; + Some(NameOrNameRef::Name(name)) + } + _ => None, + }, + _ => None, } - None } } -- cgit v1.2.3