diff options
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 605951b10..ca005bc99 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -137,10 +137,24 @@ impl<'a> InferenceContext<'a> { | |||
137 | 137 | ||
138 | self.coerce_merge_branch(&then_ty, &else_ty) | 138 | self.coerce_merge_branch(&then_ty, &else_ty) |
139 | } | 139 | } |
140 | Expr::Block { statements, tail, .. } => { | 140 | Expr::Block { statements, tail, label } => match label { |
141 | // FIXME: Breakable block inference | 141 | Some(_) => { |
142 | self.infer_block(statements, *tail, expected) | 142 | let break_ty = self.table.new_type_var(); |
143 | } | 143 | self.breakables.push(BreakableContext { |
144 | may_break: false, | ||
145 | break_ty: break_ty.clone(), | ||
146 | label: label.clone(), | ||
147 | }); | ||
148 | let ty = self.infer_block(statements, *tail, &Expectation::has_type(break_ty)); | ||
149 | let ctxt = self.breakables.pop().expect("breakable stack broken"); | ||
150 | if ctxt.may_break { | ||
151 | ctxt.break_ty | ||
152 | } else { | ||
153 | ty | ||
154 | } | ||
155 | } | ||
156 | None => self.infer_block(statements, *tail, expected), | ||
157 | }, | ||
144 | Expr::Unsafe { body } => self.infer_expr(*body, expected), | 158 | Expr::Unsafe { body } => self.infer_expr(*body, expected), |
145 | Expr::TryBlock { body } => { | 159 | Expr::TryBlock { body } => { |
146 | let _inner = self.infer_expr(*body, expected); | 160 | let _inner = self.infer_expr(*body, expected); |
@@ -848,6 +862,7 @@ impl<'a> InferenceContext<'a> { | |||
848 | let ty = self.make_ty(type_ref); | 862 | let ty = self.make_ty(type_ref); |
849 | substs.push(ty); | 863 | substs.push(ty); |
850 | } | 864 | } |
865 | GenericArg::Lifetime(_) => {} | ||
851 | } | 866 | } |
852 | } | 867 | } |
853 | }; | 868 | }; |