diff options
Diffstat (limited to 'crates/ra_hir_def/src/body/lower.rs')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 209907700..ec1b0c2e7 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -14,7 +14,7 @@ use ra_syntax::{ | |||
14 | }; | 14 | }; |
15 | use test_utils::tested_by; | 15 | use test_utils::tested_by; |
16 | 16 | ||
17 | use super::ExprSource; | 17 | use super::{ExprSource, PatSource}; |
18 | use crate::{ | 18 | use crate::{ |
19 | adt::StructKind, | 19 | adt::StructKind, |
20 | body::{Body, BodySourceMap, Expander, PatPtr, SyntheticSyntax}, | 20 | body::{Body, BodySourceMap, Expander, PatPtr, SyntheticSyntax}, |
@@ -133,14 +133,18 @@ where | |||
133 | } | 133 | } |
134 | 134 | ||
135 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { | 135 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { |
136 | let id = self.body.pats.alloc(pat); | ||
137 | let src = self.expander.to_source(ptr); | 136 | let src = self.expander.to_source(ptr); |
137 | let id = self.make_pat(pat, Ok(src)); | ||
138 | self.source_map.pat_map.insert(src, id); | 138 | self.source_map.pat_map.insert(src, id); |
139 | self.source_map.pat_map_back.insert(id, src); | ||
140 | id | 139 | id |
141 | } | 140 | } |
142 | fn missing_pat(&mut self) -> PatId { | 141 | fn missing_pat(&mut self) -> PatId { |
143 | self.body.pats.alloc(Pat::Missing) | 142 | self.make_pat(Pat::Missing, Err(SyntheticSyntax)) |
143 | } | ||
144 | fn make_pat(&mut self, pat: Pat, src: Result<PatSource, SyntheticSyntax>) -> PatId { | ||
145 | let id = self.body.pats.alloc(pat); | ||
146 | self.source_map.pat_map_back.insert(id, src); | ||
147 | id | ||
144 | } | 148 | } |
145 | 149 | ||
146 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { | 150 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { |