]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_infer/infer/error_reporting/mod.rs
Provide better spans for the match arm without tail expression
[rust.git] / src / librustc_infer / infer / error_reporting / mod.rs
index 2b2c42207e48b6b62117b10b0023ae53a3dfac0b..8212958510a6f88bb5a672b35c5e1cccdb583a69 100644 (file)
@@ -609,6 +609,7 @@ fn note_error_origin(
                 err.span_label(span, "expected due to this");
             }
             ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
+                semi_span,
                 source,
                 ref prior_arms,
                 last_ty,
@@ -663,6 +664,14 @@ fn note_error_origin(
                             format!("this and all prior arms are found to be of type `{}`", t),
                         );
                     }
+                    if let Some(sp) = semi_span {
+                        err.span_suggestion_short(
+                            sp,
+                            "consider removing this semicolon",
+                            String::new(),
+                            Applicability::MachineApplicable,
+                        );
+                    }
                 }
             },
             ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {