Don't add label to the match expr when the type is not fully realized

This commit is contained in:
Esteban Küber 2019-01-06 14:31:39 -08:00
parent 72d965f7b7
commit 486ecc5e27
5 changed files with 4 additions and 14 deletions

View File

@ -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 { .. } => {

View File

@ -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
|

View File

@ -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
|

View File

@ -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`

View File

@ -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
|