aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body/lower.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-12-15 18:23:51 +0000
committerLukas Wirth <[email protected]>2020-12-16 13:16:09 +0000
commitdd496223f50232fe98312ee8edc89eb4b5ee3d85 (patch)
tree4d50c04ca78f9458ab536ff1edee76eba6ab1957 /crates/hir_def/src/body/lower.rs
parentd34611633b3b2404188b9e12b08c5def589808c2 (diff)
Node-ify lifetimes
Diffstat (limited to 'crates/hir_def/src/body/lower.rs')
-rw-r--r--crates/hir_def/src/body/lower.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 23e2fd764..3b3d74987 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -233,8 +233,7 @@ impl ExprCollector<'_> {
233 let res = self.collect_block(block); 233 let res = self.collect_block(block);
234 match &mut self.body.exprs[res] { 234 match &mut self.body.exprs[res] {
235 Expr::Block { label: block_label, .. } => { 235 Expr::Block { label: block_label, .. } => {
236 *block_label = 236 *block_label = label.lifetime().map(|t| Name::new_lifetime(&t))
237 label.lifetime_token().map(|t| Name::new_lifetime(&t))
238 } 237 }
239 _ => unreachable!(), 238 _ => unreachable!(),
240 } 239 }
@@ -254,10 +253,7 @@ impl ExprCollector<'_> {
254 self.alloc_expr( 253 self.alloc_expr(
255 Expr::Loop { 254 Expr::Loop {
256 body, 255 body,
257 label: e 256 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
258 .label()
259 .and_then(|l| l.lifetime_token())
260 .map(|l| Name::new_lifetime(&l)),
261 }, 257 },
262 syntax_ptr, 258 syntax_ptr,
263 ) 259 )
@@ -288,7 +284,7 @@ impl ExprCollector<'_> {
288 body: match_expr, 284 body: match_expr,
289 label: e 285 label: e
290 .label() 286 .label()
291 .and_then(|l| l.lifetime_token()) 287 .and_then(|l| l.lifetime())
292 .map(|l| Name::new_lifetime(&l)), 288 .map(|l| Name::new_lifetime(&l)),
293 }, 289 },
294 syntax_ptr, 290 syntax_ptr,
@@ -301,10 +297,7 @@ impl ExprCollector<'_> {
301 Expr::While { 297 Expr::While {
302 condition, 298 condition,
303 body, 299 body,
304 label: e 300 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
305 .label()
306 .and_then(|l| l.lifetime_token())
307 .map(|l| Name::new_lifetime(&l)),
308 }, 301 },
309 syntax_ptr, 302 syntax_ptr,
310 ) 303 )
@@ -318,10 +311,7 @@ impl ExprCollector<'_> {
318 iterable, 311 iterable,
319 pat, 312 pat,
320 body, 313 body,
321 label: e 314 label: e.label().and_then(|l| l.lifetime()).map(|l| Name::new_lifetime(&l)),
322 .label()
323 .and_then(|l| l.lifetime_token())
324 .map(|l| Name::new_lifetime(&l)),
325 }, 315 },
326 syntax_ptr, 316 syntax_ptr,
327 ) 317 )
@@ -380,13 +370,13 @@ impl ExprCollector<'_> {
380 self.alloc_expr(path, syntax_ptr) 370 self.alloc_expr(path, syntax_ptr)
381 } 371 }
382 ast::Expr::ContinueExpr(e) => self.alloc_expr( 372 ast::Expr::ContinueExpr(e) => self.alloc_expr(
383 Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, 373 Expr::Continue { label: e.lifetime().map(|l| Name::new_lifetime(&l)) },
384 syntax_ptr, 374 syntax_ptr,
385 ), 375 ),
386 ast::Expr::BreakExpr(e) => { 376 ast::Expr::BreakExpr(e) => {
387 let expr = e.expr().map(|e| self.collect_expr(e)); 377 let expr = e.expr().map(|e| self.collect_expr(e));
388 self.alloc_expr( 378 self.alloc_expr(
389 Expr::Break { expr, label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, 379 Expr::Break { expr, label: e.lifetime().map(|l| Name::new_lifetime(&l)) },
390 syntax_ptr, 380 syntax_ptr,
391 ) 381 )
392 } 382 }