@@ -137,24 +137,33 @@ impl<'a> InferenceContext<'a> {
137137
138138 self . coerce_merge_branch ( & then_ty, & else_ty)
139139 }
140- Expr :: Block { statements, tail, label, id : _ } => match label {
141- Some ( _) => {
142- let break_ty = self . table . new_type_var ( ) ;
143- self . breakables . push ( BreakableContext {
144- may_break : false ,
145- break_ty : break_ty. clone ( ) ,
146- label : label. map ( |label| self . body [ label] . name . 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
140+ Expr :: Block { statements, tail, label, id : _ } => {
141+ let old_resolver = mem:: replace (
142+ & mut self . resolver ,
143+ resolver_for_expr ( self . db . upcast ( ) , self . owner , tgt_expr) ,
144+ ) ;
145+ let ty = match label {
146+ Some ( _) => {
147+ let break_ty = self . table . new_type_var ( ) ;
148+ self . breakables . push ( BreakableContext {
149+ may_break : false ,
150+ break_ty : break_ty. clone ( ) ,
151+ label : label. map ( |label| self . body [ label] . name . clone ( ) ) ,
152+ } ) ;
153+ let ty =
154+ self . infer_block ( statements, * tail, & Expectation :: has_type ( break_ty) ) ;
155+ let ctxt = self . breakables . pop ( ) . expect ( "breakable stack broken" ) ;
156+ if ctxt. may_break {
157+ ctxt. break_ty
158+ } else {
159+ ty
160+ }
154161 }
155- }
156- None => self . infer_block ( statements, * tail, expected) ,
157- } ,
162+ None => self . infer_block ( statements, * tail, expected) ,
163+ } ;
164+ self . resolver = old_resolver;
165+ ty
166+ }
158167 Expr :: Unsafe { body } | Expr :: Const { body } => self . infer_expr ( * body, expected) ,
159168 Expr :: TryBlock { body } => {
160169 let _inner = self . infer_expr ( * body, expected) ;
0 commit comments