aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir_def/src/body/lower.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index fdd2be843..c6bc85e2f 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -313,20 +313,20 @@ impl ExprCollector<'_> {
313 } else { 313 } else {
314 Vec::new() 314 Vec::new()
315 }; 315 };
316 self.alloc_expr(Expr::Call { callee, args: args.clone() }, syntax_ptr) 316 self.alloc_expr(Expr::Call { callee, args }, syntax_ptr)
317 } 317 }
318 ast::Expr::MethodCallExpr(e) => { 318 ast::Expr::MethodCallExpr(e) => {
319 let receiver = self.collect_expr_opt(e.expr()); 319 let receiver = self.collect_expr_opt(e.expr());
320 let args = if let Some(arg_list) = e.arg_list() { 320 let args = if let Some(arg_list) = e.arg_list() {
321 arg_list.args().map(|e| self.collect_expr(e)).collect() 321 arg_list.args().map(|e| self.collect_expr(e)).collect()
322 } else { 322 } else {
323 vec![] 323 Vec::new()
324 }; 324 };
325 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); 325 let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
326 let generic_args = 326 let generic_args =
327 e.type_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it)); 327 e.type_arg_list().and_then(|it| GenericArgs::from_ast(&self.ctx(), it));
328 self.alloc_expr( 328 self.alloc_expr(
329 Expr::MethodCall { receiver, method_name, args: args.clone(), generic_args }, 329 Expr::MethodCall { receiver, method_name, args, generic_args },
330 syntax_ptr, 330 syntax_ptr,
331 ) 331 )
332 } 332 }
@@ -345,7 +345,7 @@ impl ExprCollector<'_> {
345 }) 345 })
346 .collect() 346 .collect()
347 } else { 347 } else {
348 vec![] 348 Vec::new()
349 }; 349 };
350 self.alloc_expr(Expr::Match { expr, arms }, syntax_ptr) 350 self.alloc_expr(Expr::Match { expr, arms }, syntax_ptr)
351 } 351 }
@@ -392,15 +392,17 @@ impl ExprCollector<'_> {
392 } 392 }
393 let name = field.field_name()?.as_name(); 393 let name = field.field_name()?.as_name();
394 394
395 let expr = match field.expr() { 395 Some(RecordLitField {
396 Some(e) => self.collect_expr(e), 396 name,
397 None => self.missing_expr(), 397 expr: match field.expr() {
398 }; 398 Some(e) => self.collect_expr(e),
399 Some(RecordLitField { name, expr }) 399 None => self.missing_expr(),
400 },
401 })
400 }) 402 })
401 .collect(); 403 .collect();
402 let spread = nfl.spread().map(|s| self.collect_expr(s)); 404 let spread = nfl.spread().map(|s| self.collect_expr(s));
403 Expr::RecordLit { path, fields, spread: spread } 405 Expr::RecordLit { path, fields, spread }
404 } else { 406 } else {
405 Expr::RecordLit { path, fields: Vec::new(), spread: None } 407 Expr::RecordLit { path, fields: Vec::new(), spread: None }
406 }; 408 };
@@ -484,8 +486,8 @@ impl ExprCollector<'_> {
484 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr) 486 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
485 } 487 }
486 ast::Expr::TupleExpr(e) => { 488 ast::Expr::TupleExpr(e) => {
487 let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect::<Vec<_>>(); 489 let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect();
488 self.alloc_expr(Expr::Tuple { exprs: exprs.clone() }, syntax_ptr) 490 self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
489 } 491 }
490 ast::Expr::BoxExpr(e) => { 492 ast::Expr::BoxExpr(e) => {
491 let expr = self.collect_expr_opt(e.expr()); 493 let expr = self.collect_expr_opt(e.expr());
@@ -497,8 +499,8 @@ impl ExprCollector<'_> {
497 499
498 match kind { 500 match kind {
499 ArrayExprKind::ElementList(e) => { 501 ArrayExprKind::ElementList(e) => {
500 let exprs = e.map(|expr| self.collect_expr(expr)).collect::<Vec<_>>(); 502 let exprs = e.map(|expr| self.collect_expr(expr)).collect();
501 self.alloc_expr(Expr::Array(Array::ElementList(exprs.clone())), syntax_ptr) 503 self.alloc_expr(Expr::Array(Array::ElementList(exprs)), syntax_ptr)
502 } 504 }
503 ArrayExprKind::Repeat { initializer, repeat } => { 505 ArrayExprKind::Repeat { initializer, repeat } => {
504 let initializer = self.collect_expr_opt(initializer); 506 let initializer = self.collect_expr_opt(initializer);