This commit is contained in:
robojumper 2020-05-31 12:06:22 +02:00
parent 1cd78a3355
commit cc6ba84c40
2 changed files with 21 additions and 11 deletions

View file

@ -218,7 +218,10 @@ impl ExprCollector<'_> {
self.alloc_expr( self.alloc_expr(
Expr::Loop { Expr::Loop {
body, body,
label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), label: e
.label()
.and_then(|l| l.lifetime_token())
.map(|l| Name::new_lifetime(&l)),
}, },
syntax_ptr, syntax_ptr,
) )
@ -247,7 +250,10 @@ impl ExprCollector<'_> {
return self.alloc_expr( return self.alloc_expr(
Expr::Loop { Expr::Loop {
body: match_expr, body: match_expr,
label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), label: e
.label()
.and_then(|l| l.lifetime_token())
.map(|l| Name::new_lifetime(&l)),
}, },
syntax_ptr, syntax_ptr,
); );
@ -259,7 +265,10 @@ impl ExprCollector<'_> {
Expr::While { Expr::While {
condition, condition,
body, body,
label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), label: e
.label()
.and_then(|l| l.lifetime_token())
.map(|l| Name::new_lifetime(&l)),
}, },
syntax_ptr, syntax_ptr,
) )
@ -273,7 +282,10 @@ impl ExprCollector<'_> {
iterable, iterable,
pat, pat,
body, body,
label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), label: e
.label()
.and_then(|l| l.lifetime_token())
.map(|l| Name::new_lifetime(&l)),
}, },
syntax_ptr, syntax_ptr,
) )
@ -329,12 +341,10 @@ impl ExprCollector<'_> {
.unwrap_or(Expr::Missing); .unwrap_or(Expr::Missing);
self.alloc_expr(path, syntax_ptr) self.alloc_expr(path, syntax_ptr)
} }
ast::Expr::ContinueExpr(e) => { ast::Expr::ContinueExpr(e) => self.alloc_expr(
self.alloc_expr(
Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) },
syntax_ptr, syntax_ptr,
) ),
}
ast::Expr::BreakExpr(e) => { ast::Expr::BreakExpr(e) => {
let expr = e.expr().map(|e| self.collect_expr(e)); let expr = e.expr().map(|e| self.collect_expr(e));
self.alloc_expr( self.alloc_expr(

View file

@ -275,7 +275,7 @@ impl Expr {
f(arm.expr); f(arm.expr);
} }
} }
Expr::Continue { .. } => {}, Expr::Continue { .. } => {}
Expr::Break { expr, .. } | Expr::Return { expr } => { Expr::Break { expr, .. } | Expr::Return { expr } => {
if let Some(expr) = expr { if let Some(expr) = expr {
f(*expr); f(*expr);