aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/expr.rs')
-rw-r--r--crates/ra_hir_def/src/expr.rs26
1 files changed, 19 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs
index aad12e123..ca49b26d1 100644
--- a/crates/ra_hir_def/src/expr.rs
+++ b/crates/ra_hir_def/src/expr.rs
@@ -19,7 +19,7 @@ use ra_syntax::ast::RangeOp;
19use crate::{ 19use crate::{
20 builtin_type::{BuiltinFloat, BuiltinInt}, 20 builtin_type::{BuiltinFloat, BuiltinInt},
21 path::{GenericArgs, Path}, 21 path::{GenericArgs, Path},
22 type_ref::{Mutability, TypeRef}, 22 type_ref::{Mutability, Rawness, TypeRef},
23}; 23};
24 24
25pub type ExprId = Idx<Expr>; 25pub type ExprId = Idx<Expr>;
@@ -52,18 +52,22 @@ pub enum Expr {
52 Block { 52 Block {
53 statements: Vec<Statement>, 53 statements: Vec<Statement>,
54 tail: Option<ExprId>, 54 tail: Option<ExprId>,
55 label: Option<Name>,
55 }, 56 },
56 Loop { 57 Loop {
57 body: ExprId, 58 body: ExprId,
59 label: Option<Name>,
58 }, 60 },
59 While { 61 While {
60 condition: ExprId, 62 condition: ExprId,
61 body: ExprId, 63 body: ExprId,
64 label: Option<Name>,
62 }, 65 },
63 For { 66 For {
64 iterable: ExprId, 67 iterable: ExprId,
65 pat: PatId, 68 pat: PatId,
66 body: ExprId, 69 body: ExprId,
70 label: Option<Name>,
67 }, 71 },
68 Call { 72 Call {
69 callee: ExprId, 73 callee: ExprId,
@@ -79,9 +83,12 @@ pub enum Expr {
79 expr: ExprId, 83 expr: ExprId,
80 arms: Vec<MatchArm>, 84 arms: Vec<MatchArm>,
81 }, 85 },
82 Continue, 86 Continue {
87 label: Option<Name>,
88 },
83 Break { 89 Break {
84 expr: Option<ExprId>, 90 expr: Option<ExprId>,
91 label: Option<Name>,
85 }, 92 },
86 Return { 93 Return {
87 expr: Option<ExprId>, 94 expr: Option<ExprId>,
@@ -101,12 +108,16 @@ pub enum Expr {
101 Try { 108 Try {
102 expr: ExprId, 109 expr: ExprId,
103 }, 110 },
111 TryBlock {
112 body: ExprId,
113 },
104 Cast { 114 Cast {
105 expr: ExprId, 115 expr: ExprId,
106 type_ref: TypeRef, 116 type_ref: TypeRef,
107 }, 117 },
108 Ref { 118 Ref {
109 expr: ExprId, 119 expr: ExprId,
120 rawness: Rawness,
110 mutability: Mutability, 121 mutability: Mutability,
111 }, 122 },
112 Box { 123 Box {
@@ -221,7 +232,7 @@ impl Expr {
221 f(*else_branch); 232 f(*else_branch);
222 } 233 }
223 } 234 }
224 Expr::Block { statements, tail } => { 235 Expr::Block { statements, tail, .. } => {
225 for stmt in statements { 236 for stmt in statements {
226 match stmt { 237 match stmt {
227 Statement::Let { initializer, .. } => { 238 Statement::Let { initializer, .. } => {
@@ -236,8 +247,9 @@ impl Expr {
236 f(*expr); 247 f(*expr);
237 } 248 }
238 } 249 }
239 Expr::Loop { body } => f(*body), 250 Expr::TryBlock { body } => f(*body),
240 Expr::While { condition, body } => { 251 Expr::Loop { body, .. } => f(*body),
252 Expr::While { condition, body, .. } => {
241 f(*condition); 253 f(*condition);
242 f(*body); 254 f(*body);
243 } 255 }
@@ -263,8 +275,8 @@ impl Expr {
263 f(arm.expr); 275 f(arm.expr);
264 } 276 }
265 } 277 }
266 Expr::Continue => {} 278 Expr::Continue { .. } => {}
267 Expr::Break { expr } | Expr::Return { expr } => { 279 Expr::Break { expr, .. } | Expr::Return { expr } => {
268 if let Some(expr) = expr { 280 if let Some(expr) = expr {
269 f(*expr); 281 f(*expr);
270 } 282 }