diff options
author | Benjamin Coenen <[email protected]> | 2020-04-18 16:14:24 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-04-18 16:14:24 +0100 |
commit | af3c19e85f55db9277ce9ad5b784df2ccfe3c9e4 (patch) | |
tree | 7a777f22f5fa79704b8d2c9aa8d67255d12123be /crates/ra_hir_def/src/body | |
parent | 379787858bbfb2691e134942d94fcbc70c5d1d7f (diff) | |
parent | 84e3304a9bf0d68e30d58b1e37a6db2e9ec97525 (diff) |
Merge branch 'master' of github.com:rust-analyzer/rust-analyzer
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 79abe55ce..82a52804d 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -320,7 +320,8 @@ impl ExprCollector<'_> { | |||
320 | 320 | ||
321 | let res = self.alloc_expr(record_lit, syntax_ptr); | 321 | let res = self.alloc_expr(record_lit, syntax_ptr); |
322 | for (i, ptr) in field_ptrs.into_iter().enumerate() { | 322 | for (i, ptr) in field_ptrs.into_iter().enumerate() { |
323 | self.source_map.field_map.insert((res, i), ptr); | 323 | let src = self.expander.to_source(ptr); |
324 | self.source_map.field_map.insert((res, i), src); | ||
324 | } | 325 | } |
325 | res | 326 | res |
326 | } | 327 | } |
@@ -650,6 +651,7 @@ impl ExprCollector<'_> { | |||
650 | ast::Pat::SlicePat(p) => { | 651 | ast::Pat::SlicePat(p) => { |
651 | let SlicePatComponents { prefix, slice, suffix } = p.components(); | 652 | let SlicePatComponents { prefix, slice, suffix } = p.components(); |
652 | 653 | ||
654 | // FIXME properly handle `DotDotPat` | ||
653 | Pat::Slice { | 655 | Pat::Slice { |
654 | prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(), | 656 | prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(), |
655 | slice: slice.map(|p| self.collect_pat(p)), | 657 | slice: slice.map(|p| self.collect_pat(p)), |
@@ -666,9 +668,15 @@ impl ExprCollector<'_> { | |||
666 | Pat::Missing | 668 | Pat::Missing |
667 | } | 669 | } |
668 | } | 670 | } |
669 | ast::Pat::DotDotPat(_) => unreachable!( | 671 | ast::Pat::DotDotPat(_) => { |
670 | "`DotDotPat` requires special handling and should not be mapped to a Pat." | 672 | // `DotDotPat` requires special handling and should not be mapped |
671 | ), | 673 | // to a Pat. Here we are using `Pat::Missing` as a fallback for |
674 | // when `DotDotPat` is mapped to `Pat`, which can easily happen | ||
675 | // when the source code being analyzed has a malformed pattern | ||
676 | // which includes `..` in a place where it isn't valid. | ||
677 | |||
678 | Pat::Missing | ||
679 | } | ||
672 | // FIXME: implement | 680 | // FIXME: implement |
673 | ast::Pat::BoxPat(_) | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, | 681 | ast::Pat::BoxPat(_) | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, |
674 | }; | 682 | }; |