diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index eec92675af68..f71cce8273c4 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -488,7 +488,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn note_error_origin(&self, err: &mut DiagnosticBuilder<'tcx>, cause: &ObligationCause<'tcx>) { match cause.code { ObligationCauseCode::MatchExpressionArmPattern { span, ty } => { - err.span_label(span, format!("this match expression has type `{}`", ty)); + if ty.is_suggestable() { // don't show type `_` + err.span_label(span, format!("this match expression has type `{}`", ty)); + } } ObligationCauseCode::MatchExpressionArm { arm_span, source } => match source { hir::MatchSource::IfLetDesugar { .. } => { diff --git a/src/test/ui/match/match-range-fail.stderr b/src/test/ui/match/match-range-fail.stderr index 532f5e23ff5e..54969927433a 100644 --- a/src/test/ui/match/match-range-fail.stderr +++ b/src/test/ui/match/match-range-fail.stderr @@ -19,8 +19,6 @@ LL | 10 ..= "what" => () error[E0308]: mismatched types --> $DIR/match-range-fail.rs:17:9 | -LL | match 5 { - | - this match expression has type `{integer}` LL | 'c' ..= 100 => { } | ^^^^^^^^^^^ expected integer, found char | diff --git a/src/test/ui/mismatched_types/E0409.stderr b/src/test/ui/mismatched_types/E0409.stderr index a73f9ab4dfdd..08f132efd052 100644 --- a/src/test/ui/mismatched_types/E0409.stderr +++ b/src/test/ui/mismatched_types/E0409.stderr @@ -9,8 +9,6 @@ LL | (0, ref y) | (y, 0) => {} //~ ERROR E0409 error[E0308]: mismatched types --> $DIR/E0409.rs:5:23 | -LL | match x { - | - this match expression has type `_` LL | (0, ref y) | (y, 0) => {} //~ ERROR E0409 | ^ expected &{integer}, found integer | diff --git a/src/test/ui/or-pattern-mismatch.stderr b/src/test/ui/or-pattern-mismatch.stderr index c3a203cf3ab6..731b2090a7ba 100644 --- a/src/test/ui/or-pattern-mismatch.stderr +++ b/src/test/ui/or-pattern-mismatch.stderr @@ -2,9 +2,7 @@ error[E0308]: mismatched types --> $DIR/or-pattern-mismatch.rs:3:68 | LL | fn main() { match Blah::A(1, 1, 2) { Blah::A(_, x, y) | Blah::B(x, y) => { } } } - | ---------------- ^ expected usize, found isize - | | - | this match expression has type `_` + | ^ expected usize, found isize | = note: expected type `usize` found type `isize` diff --git a/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr index 148f084e401a..a14d3d67b10a 100644 --- a/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr +++ b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr @@ -23,8 +23,6 @@ LL | Opts::A(ref mut i) | Opts::B(ref i) => {} error[E0308]: mismatched types --> $DIR/resolve-inconsistent-binding-mode.rs:7:32 | -LL | match x { - | - this match expression has type `_` LL | Opts::A(ref i) | Opts::B(i) => {} | ^ expected &isize, found isize | @@ -34,8 +32,6 @@ LL | Opts::A(ref i) | Opts::B(i) => {} error[E0308]: mismatched types --> $DIR/resolve-inconsistent-binding-mode.rs:16:32 | -LL | match x { - | - this match expression has type `_` LL | Opts::A(ref i) | Opts::B(i) => {} | ^ expected &isize, found isize | @@ -45,8 +41,6 @@ LL | Opts::A(ref i) | Opts::B(i) => {} error[E0308]: mismatched types --> $DIR/resolve-inconsistent-binding-mode.rs:25:36 | -LL | match x { - | - this match expression has type `_` LL | Opts::A(ref mut i) | Opts::B(ref i) => {} | ^^^^^ types differ in mutability |