@@ -1218,7 +1218,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
12181218 self . pushed += 1 ;
12191219 }
12201220 }
1221- Err ( err ) => {
1221+ Err ( coercion_error ) => {
12221222 let ( expected, found) = if label_expression_as_expected {
12231223 // In the case where this is a "forced unit", like
12241224 // `break`, we want to call the `()` "expected"
@@ -1234,41 +1234,42 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
12341234 ( self . final_ty . unwrap_or ( self . expected_ty ) , expression_ty)
12351235 } ;
12361236
1237- let mut db ;
1237+ let mut err ;
12381238 match cause. code {
12391239 ObligationCauseCode :: ReturnNoExpression => {
1240- db = struct_span_err ! (
1240+ err = struct_span_err ! (
12411241 fcx. tcx. sess, cause. span, E0069 ,
12421242 "`return;` in a function whose return type is not `()`" ) ;
1243- db . span_label ( cause. span , "return type is not `()`" ) ;
1243+ err . span_label ( cause. span , "return type is not `()`" ) ;
12441244 }
12451245 ObligationCauseCode :: BlockTailExpression ( blk_id) => {
12461246 let parent_id = fcx. tcx . hir ( ) . get_parent_node ( blk_id) ;
1247- db = self . report_return_mismatched_types (
1247+ err = self . report_return_mismatched_types (
12481248 cause,
12491249 expected,
12501250 found,
1251- err ,
1251+ coercion_error ,
12521252 fcx,
12531253 parent_id,
12541254 expression. map ( |expr| ( expr, blk_id) ) ,
12551255 ) ;
12561256 }
12571257 ObligationCauseCode :: ReturnValue ( id) => {
1258- db = self . report_return_mismatched_types (
1259- cause, expected, found, err , fcx, id, None ) ;
1258+ err = self . report_return_mismatched_types (
1259+ cause, expected, found, coercion_error , fcx, id, None ) ;
12601260 }
12611261 _ => {
1262- db = fcx. report_mismatched_types ( cause, expected, found, err ) ;
1262+ err = fcx. report_mismatched_types ( cause, expected, found, coercion_error ) ;
12631263 }
12641264 }
12651265
12661266 if let Some ( augment_error) = augment_error {
1267- augment_error ( & mut db ) ;
1267+ augment_error ( & mut err ) ;
12681268 }
12691269
12701270 // Error possibly reported in `check_assign` so avoid emitting error again.
1271- db. emit_unless ( expression. filter ( |e| fcx. is_assign_to_bool ( e, expected) ) . is_some ( ) ) ;
1271+ err. emit_unless ( expression. filter ( |e| fcx. is_assign_to_bool ( e, expected) )
1272+ . is_some ( ) ) ;
12721273
12731274 self . final_ty = Some ( fcx. tcx . types . err ) ;
12741275 }
@@ -1280,12 +1281,12 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
12801281 cause : & ObligationCause < ' tcx > ,
12811282 expected : Ty < ' tcx > ,
12821283 found : Ty < ' tcx > ,
1283- err : TypeError < ' tcx > ,
1284+ ty_err : TypeError < ' tcx > ,
12841285 fcx : & FnCtxt < ' a , ' tcx > ,
12851286 id : hir:: HirId ,
12861287 expression : Option < ( & ' tcx hir:: Expr , hir:: HirId ) > ,
12871288 ) -> DiagnosticBuilder < ' a > {
1288- let mut db = fcx. report_mismatched_types ( cause, expected, found, err ) ;
1289+ let mut err = fcx. report_mismatched_types ( cause, expected, found, ty_err ) ;
12891290
12901291 let mut pointing_at_return_type = false ;
12911292 let mut return_sp = None ;
@@ -1296,7 +1297,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
12961297 let parent_id = fcx. tcx . hir ( ) . get_parent_node ( id) ;
12971298 let fn_decl = if let Some ( ( expr, blk_id) ) = expression {
12981299 pointing_at_return_type = fcx. suggest_mismatched_types_on_tail (
1299- & mut db ,
1300+ & mut err ,
13001301 expr,
13011302 expected,
13021303 found,
@@ -1310,8 +1311,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13101311 pointing_at_return_type,
13111312 ) {
13121313 if match_expr. span . desugaring_kind ( ) . is_none ( ) {
1313- db . span_label ( match_expr. span , "expected this to be `()`" ) ;
1314- db . span_suggestion_short (
1314+ err . span_laber ( match_expr. span , "expected this to be `()`" ) ;
1315+ err . span_suggestion_short (
13151316 match_expr. span . shrink_to_hi ( ) ,
13161317 "consider using a semicolon here" ,
13171318 ";" . to_string ( ) ,
@@ -1327,20 +1328,20 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13271328 if let ( Some ( ( fn_decl, can_suggest) ) , _) = ( fn_decl, pointing_at_return_type) {
13281329 if expression. is_none ( ) {
13291330 pointing_at_return_type |= fcx. suggest_missing_return_type (
1330- & mut db , & fn_decl, expected, found, can_suggest) ;
1331+ & mut err , & fn_decl, expected, found, can_suggest) ;
13311332 }
13321333 if !pointing_at_return_type {
13331334 return_sp = Some ( fn_decl. output . span ( ) ) ; // `impl Trait` return type
13341335 }
13351336 }
13361337 if let ( Some ( sp) , Some ( return_sp) ) = ( fcx. ret_coercion_span . borrow ( ) . as_ref ( ) , return_sp) {
1337- db . span_label ( return_sp, "expected because this return type..." ) ;
1338- db . span_label ( * sp, format ! (
1338+ err . span_label ( return_sp, "expected because this return type..." ) ;
1339+ err . span_label ( * sp, format ! (
13391340 "...is found to be `{}` here" ,
13401341 fcx. resolve_type_vars_with_obligations( expected) ,
13411342 ) ) ;
13421343 }
1343- db
1344+ err
13441345 }
13451346
13461347 pub fn complete < ' a > ( self , fcx : & FnCtxt < ' a , ' tcx > ) -> Ty < ' tcx > {
0 commit comments