diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-15 18:51:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-15 18:51:23 +0000 |
commit | 382361c252f6d9e1c9e3fad3bdc4ebe32c5d4b7b (patch) | |
tree | 60e0e6ccfab323471d18e4d5568e8da735af56c6 /crates/syntax/src/ast/expr_ext.rs | |
parent | e8c803937ce23a6cf74583ad03f9868869c7eea1 (diff) | |
parent | f3e297331c5c4b8c03810acc745ae5b4a9c4f71f (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/expr_ext.rs')
-rw-r--r-- | crates/syntax/src/ast/expr_ext.rs | 12 |
1 files changed, 12 insertions, 0 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)] |