aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-15 18:51:23 +0000
committerGitHub <[email protected]>2020-11-15 18:51:23 +0000
commit382361c252f6d9e1c9e3fad3bdc4ebe32c5d4b7b (patch)
tree60e0e6ccfab323471d18e4d5568e8da735af56c6 /crates/syntax/src/ast
parente8c803937ce23a6cf74583ad03f9868869c7eea1 (diff)
parentf3e297331c5c4b8c03810acc745ae5b4a9c4f71f (diff)
Merge #6552
6552: Properly handle shorthands in destructure patterns when renaming r=SomeoneToIgnore a=Veykril Fixes #6548 and #6551. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r--crates/syntax/src/ast/expr_ext.rs12
-rw-r--r--crates/syntax/src/ast/node_ext.rs10
2 files changed, 13 insertions, 9 deletions
diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs
index 9253c97d0..e4a9b945c 100644
--- a/crates/syntax/src/ast/expr_ext.rs
+++ b/crates/syntax/src/ast/expr_ext.rs
@@ -22,6 +22,18 @@ impl ast::Expr {
22 _ => false, 22 _ => false,
23 } 23 }
24 } 24 }
25
26 pub fn name_ref(&self) -> Option<ast::NameRef> {
27 if let ast::Expr::PathExpr(expr) = self {
28 let path = expr.path()?;
29 let segment = path.segment()?;
30 let name_ref = segment.name_ref()?;
31 if path.qualifier().is_none() {
32 return Some(name_ref);
33 }
34 }
35 None
36 }
25} 37}
26 38
27#[derive(Debug, Clone, PartialEq, Eq)] 39#[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index ce35ac01a..b70b840b8 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -203,15 +203,7 @@ impl ast::RecordExprField {
203 if let Some(name_ref) = self.name_ref() { 203 if let Some(name_ref) = self.name_ref() {
204 return Some(name_ref); 204 return Some(name_ref);
205 } 205 }
206 if let Some(ast::Expr::PathExpr(expr)) = self.expr() { 206 self.expr()?.name_ref()
207 let path = expr.path()?;
208 let segment = path.segment()?;
209 let name_ref = segment.name_ref()?;
210 if path.qualifier().is_none() {
211 return Some(name_ref);
212 }
213 }
214 None
215 } 207 }
216} 208}
217 209