about summary refs log tree commit diff
path: root/tests/ui/pattern
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-31 13:53:40 +0000
committerbors <bors@rust-lang.org>2023-01-31 13:53:40 +0000
commitf361413cbf44ce2f144df59fc440cd484af4a56e (patch)
treececf91d94ee20df2d6bec7c88796b90fa34f9887 /tests/ui/pattern
parenta64ef7d07d0411315be85a646586cb85eeb9c136 (diff)
parent449dfc64f0792f2320ef68bc08f238281199f53d (diff)
downloadrust-f361413cbf44ce2f144df59fc440cd484af4a56e.tar.gz
rust-f361413cbf44ce2f144df59fc440cd484af4a56e.zip
Auto merge of #106399 - estebank:type-err-span-label, r=nagisa
Modify primary span label for E0308

Looking at the reactions to https://hachyderm.io/`@ekuber/109622160673605438,` a lot of people seem to have trouble understanding the current output, where the primary span label on type errors talks about the specific types that diverged, but these can be deeply nested type parameters. Because of that we could see "expected i32, found u32" in the label while the note said "expected Vec<i32>, found Vec<u32>". This understandably confuses people. I believe that once people learn to read these errors it starts to make more sense, but this PR changes the output to be more in line with what people might expect, without sacrificing terseness.

Fix #68220.
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/for-loop-bad-item.stderr2
-rw-r--r--tests/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr2
-rw-r--r--tests/ui/pattern/pat-struct-field-expr-has-type.stderr2
-rw-r--r--tests/ui/pattern/pat-type-err-formal-param.stderr2
-rw-r--r--tests/ui/pattern/pat-type-err-let-stmt.stderr8
-rw-r--r--tests/ui/pattern/pattern-error-continue.rs2
-rw-r--r--tests/ui/pattern/pattern-error-continue.stderr2
-rw-r--r--tests/ui/pattern/pattern-ident-path-generics.stderr2
-rw-r--r--tests/ui/pattern/pattern-tyvar.stderr2
9 files changed, 12 insertions, 12 deletions
diff --git a/tests/ui/pattern/for-loop-bad-item.stderr b/tests/ui/pattern/for-loop-bad-item.stderr
index f064a25a9c9..67c6d6f01a1 100644
--- a/tests/ui/pattern/for-loop-bad-item.stderr
+++ b/tests/ui/pattern/for-loop-bad-item.stderr
@@ -25,7 +25,7 @@ error[E0308]: mismatched types
 LL |     for Some(Qux(_)) | None in [Some(""), None] {
    |              ^^^^^^            ---------------- this is an iterator with items of type `Option<&str>`
    |              |
-   |              expected `str`, found struct `Qux`
+   |              expected `str`, found `Qux`
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr b/tests/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
index 75a231f6b4b..daab3a862c2 100644
--- a/tests/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
+++ b/tests/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     let P() = U {};
    |         ^^^   ---- this expression has type `U`
    |         |
-   |         expected struct `U`, found struct `P`
+   |         expected `U`, found `P<_>`
    |
    = note: expected struct `U`
               found struct `P<_>`
diff --git a/tests/ui/pattern/pat-struct-field-expr-has-type.stderr b/tests/ui/pattern/pat-struct-field-expr-has-type.stderr
index 3a61d4293b0..02907529310 100644
--- a/tests/ui/pattern/pat-struct-field-expr-has-type.stderr
+++ b/tests/ui/pattern/pat-struct-field-expr-has-type.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     match (S { f: 42 }) {
    |           ------------- this expression has type `S`
 LL |         S { f: Ok(_) } => {}
-   |                ^^^^^ expected `u8`, found enum `Result`
+   |                ^^^^^ expected `u8`, found `Result<_, _>`
    |
    = note: expected type `u8`
               found enum `Result<_, _>`
diff --git a/tests/ui/pattern/pat-type-err-formal-param.stderr b/tests/ui/pattern/pat-type-err-formal-param.stderr
index 206713a4bfc..4f482c52a98 100644
--- a/tests/ui/pattern/pat-type-err-formal-param.stderr
+++ b/tests/ui/pattern/pat-type-err-formal-param.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL | fn foo(Tuple(_): String) {}
    |        ^^^^^^^^  ------ expected due to this
    |        |
-   |        expected struct `String`, found struct `Tuple`
+   |        expected `String`, found `Tuple`
 
 error: aborting due to previous error
 
diff --git a/tests/ui/pattern/pat-type-err-let-stmt.stderr b/tests/ui/pattern/pat-type-err-let-stmt.stderr
index 090bd67117e..b68b69a78a2 100644
--- a/tests/ui/pattern/pat-type-err-let-stmt.stderr
+++ b/tests/ui/pattern/pat-type-err-let-stmt.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/pat-type-err-let-stmt.rs:6:29
    |
 LL |     let Ok(0): Option<u8> = 42u8;
-   |                ----------   ^^^^ expected enum `Option`, found `u8`
+   |                ----------   ^^^^ expected `Option<u8>`, found `u8`
    |                |
    |                expected due to this
    |
@@ -19,7 +19,7 @@ error[E0308]: mismatched types
 LL |     let Ok(0): Option<u8> = 42u8;
    |         ^^^^^  ---------- expected due to this
    |         |
-   |         expected enum `Option`, found enum `Result`
+   |         expected `Option<u8>`, found `Result<_, _>`
    |
    = note: expected enum `Option<u8>`
               found enum `Result<_, _>`
@@ -30,7 +30,7 @@ error[E0308]: mismatched types
 LL |     let Ok(0): Option<u8>;
    |         ^^^^^  ---------- expected due to this
    |         |
-   |         expected enum `Option`, found enum `Result`
+   |         expected `Option<u8>`, found `Result<_, _>`
    |
    = note: expected enum `Option<u8>`
               found enum `Result<_, _>`
@@ -41,7 +41,7 @@ error[E0308]: mismatched types
 LL |     let Ok(0) = 42u8;
    |         ^^^^^   ---- this expression has type `u8`
    |         |
-   |         expected `u8`, found enum `Result`
+   |         expected `u8`, found `Result<_, _>`
    |
    = note: expected type `u8`
               found enum `Result<_, _>`
diff --git a/tests/ui/pattern/pattern-error-continue.rs b/tests/ui/pattern/pattern-error-continue.rs
index 0702a9986fc..bed94943923 100644
--- a/tests/ui/pattern/pattern-error-continue.rs
+++ b/tests/ui/pattern/pattern-error-continue.rs
@@ -21,7 +21,7 @@ fn main() {
     match 'c' {
         S { .. } => (),
         //~^ ERROR mismatched types
-        //~| expected `char`, found struct `S`
+        //~| expected `char`, found `S`
 
         _ => ()
     }
diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr
index 4c2eff63ab5..e1349fb02ea 100644
--- a/tests/ui/pattern/pattern-error-continue.stderr
+++ b/tests/ui/pattern/pattern-error-continue.stderr
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
 LL |     match 'c' {
    |           --- this expression has type `char`
 LL |         S { .. } => (),
-   |         ^^^^^^^^ expected `char`, found struct `S`
+   |         ^^^^^^^^ expected `char`, found `S`
 
 error[E0308]: mismatched types
   --> $DIR/pattern-error-continue.rs:28:7
diff --git a/tests/ui/pattern/pattern-ident-path-generics.stderr b/tests/ui/pattern/pattern-ident-path-generics.stderr
index 01b082bd35b..62283dfe9b6 100644
--- a/tests/ui/pattern/pattern-ident-path-generics.stderr
+++ b/tests/ui/pattern/pattern-ident-path-generics.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     match Some("foo") {
    |           ----------- this expression has type `Option<&str>`
 LL |         None::<isize> => {}
-   |         ^^^^^^^^^^^^^ expected `&str`, found `isize`
+   |         ^^^^^^^^^^^^^ expected `Option<&str>`, found `Option<isize>`
    |
    = note: expected enum `Option<&str>`
               found enum `Option<isize>`
diff --git a/tests/ui/pattern/pattern-tyvar.stderr b/tests/ui/pattern/pattern-tyvar.stderr
index f1e2a9d72ce..4eb00254861 100644
--- a/tests/ui/pattern/pattern-tyvar.stderr
+++ b/tests/ui/pattern/pattern-tyvar.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     match t {
    |           - this expression has type `Bar`
 LL |       Bar::T1(_, Some::<isize>(x)) => {
-   |                  ^^^^^^^^^^^^^^^^ expected struct `Vec`, found `isize`
+   |                  ^^^^^^^^^^^^^^^^ expected `Option<Vec<isize>>`, found `Option<isize>`
    |
    = note: expected enum `Option<Vec<isize>>`
               found enum `Option<isize>`