aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/semantics.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 758d00409..872f5fa4c 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -289,8 +289,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
289 self.imp.is_unsafe_ref_expr(ref_expr) 289 self.imp.is_unsafe_ref_expr(ref_expr)
290 } 290 }
291 291
292 pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool { 292 pub fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool {
293 self.imp.is_unsafe_bind_pat(bind_pat) 293 self.imp.is_unsafe_ident_pat(ident_pat)
294 } 294 }
295} 295}
296 296
@@ -629,20 +629,24 @@ impl<'db> SemanticsImpl<'db> {
629 // more than it should with the current implementation. 629 // more than it should with the current implementation.
630 } 630 }
631 631
632 pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool { 632 pub fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool {
633 bind_pat 633 if !ident_pat.ref_token().is_some() {
634 return false;
635 }
636
637 ident_pat
634 .syntax() 638 .syntax()
635 .parent() 639 .parent()
636 .and_then(|parent| { 640 .and_then(|parent| {
637 // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or 641 // `IdentPat` can live under `RecordPat` directly under `RecordPatField` or
638 // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`, 642 // `RecordPatFieldList`. `RecordPatField` also lives under `RecordPatFieldList`,
639 // so this tries to lookup the `BindPat` anywhere along that structure to the 643 // so this tries to lookup the `IdentPat` anywhere along that structure to the
640 // `RecordPat` so we can get the containing type. 644 // `RecordPat` so we can get the containing type.
641 let record_pat = ast::RecordFieldPat::cast(parent.clone()) 645 let record_pat = ast::RecordPatField::cast(parent.clone())
642 .and_then(|record_pat| record_pat.syntax().parent()) 646 .and_then(|record_pat| record_pat.syntax().parent())
643 .or_else(|| Some(parent.clone())) 647 .or_else(|| Some(parent.clone()))
644 .and_then(|parent| { 648 .and_then(|parent| {
645 ast::RecordFieldPatList::cast(parent)? 649 ast::RecordPatFieldList::cast(parent)?
646 .syntax() 650 .syntax()
647 .parent() 651 .parent()
648 .and_then(ast::RecordPat::cast) 652 .and_then(ast::RecordPat::cast)