@@ -712,7 +712,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
712
712
opt_suggest_box_span,
713
713
} ) => {
714
714
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 ) ;
716
716
err. span_label ( then_span, "expected because of this" ) ;
717
717
if let Some ( sp) = outer_span {
718
718
err. span_label ( sp, "`if` and `else` have incompatible types" ) ;
@@ -760,11 +760,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
760
760
second_ty : Ty < ' tcx > ,
761
761
second_span : Span ,
762
762
) {
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
+ } ) ;
768
772
match remove_semicolon {
769
773
Some ( ( sp, StatementAsExpression :: NeedsBoxing ) ) => {
770
774
err. multipart_suggestion (
0 commit comments