@@ -123,7 +123,7 @@ impl Qualifs<'mir, 'tcx> {
123123 has_mut_interior. get ( ) . contains ( local) || self . indirectly_mutable ( ccx, local, location)
124124 }
125125
126- fn in_return_place ( & mut self , ccx : & ' mir ConstCx < ' mir , ' tcx > ) -> ConstQualifs {
126+ fn in_return_place ( & mut self , ccx : & ' mir ConstCx < ' mir , ' tcx > , error_occured : bool ) -> ConstQualifs {
127127 // Find the `Return` terminator if one exists.
128128 //
129129 // If no `Return` terminator exists, this MIR is divergent. Just return the conservative
@@ -139,7 +139,7 @@ impl Qualifs<'mir, 'tcx> {
139139 . map ( |( bb, _) | bb) ;
140140
141141 let return_block = match return_block {
142- None => return qualifs:: in_any_value_of_ty ( ccx, ccx. body . return_ty ( ) ) ,
142+ None => return qualifs:: in_any_value_of_ty ( ccx, ccx. body . return_ty ( ) , error_occured ) ,
143143 Some ( bb) => bb,
144144 } ;
145145
@@ -170,6 +170,7 @@ impl Qualifs<'mir, 'tcx> {
170170 needs_drop : self . needs_drop ( ccx, RETURN_PLACE , return_loc) ,
171171 has_mut_interior : self . has_mut_interior ( ccx, RETURN_PLACE , return_loc) ,
172172 custom_eq,
173+ error_occured,
173174 }
174175 }
175176}
@@ -276,7 +277,7 @@ impl Validator<'mir, 'tcx> {
276277 }
277278
278279 pub fn qualifs_in_return_place ( & mut self ) -> ConstQualifs {
279- self . qualifs . in_return_place ( self . ccx )
280+ self . qualifs . in_return_place ( self . ccx , self . error_emitted )
280281 }
281282
282283 /// Emits an error if an expression cannot be evaluated in the current context.
0 commit comments