about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-01-06 14:31:39 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-01-12 19:36:28 -0800
commit486ecc5e27992175c194b5bb12a374d15293c9c0 (patch)
tree38856bdb3a247c0433d69aa550962a93498e2207
parent72d965f7b7c2dcf0f6d076982c254093cdf96fe4 (diff)
downloadrust-486ecc5e27992175c194b5bb12a374d15293c9c0.tar.gz
rust-486ecc5e27992175c194b5bb12a374d15293c9c0.zip
Don't add label to the match expr when the type is not fully realized
-rw-r--r--src/librustc/infer/error_reporting/mod.rs4
-rw-r--r--src/test/ui/match/match-range-fail.stderr2
-rw-r--r--src/test/ui/mismatched_types/E0409.stderr2
-rw-r--r--src/test/ui/or-pattern-mismatch.stderr4
-rw-r--r--src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr6
5 files changed, 4 insertions, 14 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index eec92675af6..f71cce8273c 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 532f5e23ff5..54969927433 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 a73f9ab4dfd..08f132efd05 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 c3a203cf3ab..731b2090a7b 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 148f084e401..a14d3d67b10 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
    |