From 1cd78a3355ea70d3070cabb00c80a5d195499752 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 31 May 2020 10:59:40 +0200 Subject: correctly infer labelled breaks --- crates/ra_hir_def/src/expr.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_def/src/expr.rs') diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index f25c6f958..8683f6c7f 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -52,18 +52,22 @@ pub enum Expr { Block { statements: Vec, tail: Option, + label: Option, }, Loop { body: ExprId, + label: Option, }, While { condition: ExprId, body: ExprId, + label: Option, }, For { iterable: ExprId, pat: PatId, body: ExprId, + label: Option, }, Call { callee: ExprId, @@ -79,9 +83,12 @@ pub enum Expr { expr: ExprId, arms: Vec, }, - Continue, + Continue { + label: Option, + }, Break { expr: Option, + label: Option, }, Return { expr: Option, @@ -225,7 +232,7 @@ impl Expr { f(*else_branch); } } - Expr::Block { statements, tail } => { + Expr::Block { statements, tail, .. } => { for stmt in statements { match stmt { Statement::Let { initializer, .. } => { @@ -241,8 +248,8 @@ impl Expr { } } Expr::TryBlock { body } => f(*body), - Expr::Loop { body } => f(*body), - Expr::While { condition, body } => { + Expr::Loop { body, .. } => f(*body), + Expr::While { condition, body, .. } => { f(*condition); f(*body); } @@ -268,8 +275,8 @@ impl Expr { f(arm.expr); } } - Expr::Continue => {} - Expr::Break { expr } | Expr::Return { expr } => { + Expr::Continue { .. } => {}, + Expr::Break { expr, .. } | Expr::Return { expr } => { if let Some(expr) = expr { f(*expr); } -- cgit v1.2.3