@@ -712,7 +712,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
712712 opt_suggest_box_span,
713713 } ) => {
714714 let then_span = self . find_block_span_from_hir_id ( then_id) ;
715- let else_span = self . find_block_span_from_hir_id ( then_id ) ;
715+ let else_span = self . find_block_span_from_hir_id ( else_id ) ;
716716 err. span_label ( then_span, "expected because of this" ) ;
717717 if let Some ( sp) = outer_span {
718718 err. span_label ( sp, "`if` and `else` have incompatible types" ) ;
@@ -760,11 +760,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
760760 second_ty : Ty < ' tcx > ,
761761 second_span : Span ,
762762 ) {
763- let remove_semicolon =
764- [ ( first_id, second_ty) , ( second_id, first_ty) ] . into_iter ( ) . find_map ( |( id, ty) | {
765- let hir:: Node :: Block ( blk) = self . tcx . hir ( ) . get ( id?) else { return None } ;
766- self . could_remove_semicolon ( blk, ty)
767- } ) ;
763+ let remove_semicolon = [
764+ ( first_id, self . resolve_vars_if_possible ( second_ty) ) ,
765+ ( second_id, self . resolve_vars_if_possible ( first_ty) ) ,
766+ ]
767+ . into_iter ( )
768+ . find_map ( |( id, ty) | {
769+ let hir:: Node :: Block ( blk) = self . tcx . hir ( ) . get ( id?) else { return None } ;
770+ self . could_remove_semicolon ( blk, ty)
771+ } ) ;
768772 match remove_semicolon {
769773 Some ( ( sp, StatementAsExpression :: NeedsBoxing ) ) => {
770774 err. multipart_suggestion (
0 commit comments