about summary refs log tree commit diff
path: root/tests/ui/array-slice-vec
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/array-slice-vec
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/array-slice-vec')
-rw-r--r--tests/ui/array-slice-vec/array-not-vector.rs4
-rw-r--r--tests/ui/array-slice-vec/array-not-vector.stderr4
-rw-r--r--tests/ui/array-slice-vec/slice-to-vec-comparison.stderr2
3 files changed, 5 insertions, 5 deletions
diff --git a/tests/ui/array-slice-vec/array-not-vector.rs b/tests/ui/array-slice-vec/array-not-vector.rs
index 5e46f015baf..d8b5b10d591 100644
--- a/tests/ui/array-slice-vec/array-not-vector.rs
+++ b/tests/ui/array-slice-vec/array-not-vector.rs
@@ -1,12 +1,12 @@
 fn main() {
     let _x: i32 = [1, 2, 3];
     //~^ ERROR mismatched types
-    //~| expected `i32`, found array
+    //~| expected `i32`, found `[{integer}; 3]`
 
     let x: &[i32] = &[1, 2, 3];
     let _y: &i32 = x;
     //~^ ERROR mismatched types
     //~| expected reference `&i32`
     //~| found reference `&[i32]`
-    //~| expected `i32`, found slice
+    //~| expected `&i32`, found `&[i32]`
 }
diff --git a/tests/ui/array-slice-vec/array-not-vector.stderr b/tests/ui/array-slice-vec/array-not-vector.stderr
index 0e187d9072a..f20d99524dc 100644
--- a/tests/ui/array-slice-vec/array-not-vector.stderr
+++ b/tests/ui/array-slice-vec/array-not-vector.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/array-not-vector.rs:2:19
    |
 LL |     let _x: i32 = [1, 2, 3];
-   |             ---   ^^^^^^^^^ expected `i32`, found array `[{integer}; 3]`
+   |             ---   ^^^^^^^^^ expected `i32`, found `[{integer}; 3]`
    |             |
    |             expected due to this
 
@@ -10,7 +10,7 @@ error[E0308]: mismatched types
   --> $DIR/array-not-vector.rs:7:20
    |
 LL |     let _y: &i32 = x;
-   |             ----   ^ expected `i32`, found slice `[i32]`
+   |             ----   ^ expected `&i32`, found `&[i32]`
    |             |
    |             expected due to this
    |
diff --git a/tests/ui/array-slice-vec/slice-to-vec-comparison.stderr b/tests/ui/array-slice-vec/slice-to-vec-comparison.stderr
index e3b3b040f66..47008e1d999 100644
--- a/tests/ui/array-slice-vec/slice-to-vec-comparison.stderr
+++ b/tests/ui/array-slice-vec/slice-to-vec-comparison.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/slice-to-vec-comparison.rs:4:9
    |
 LL |     a > b;
-   |         ^ expected array of 0 elements, found struct `Vec`
+   |         ^ expected `&[_; 0]`, found `&Vec<u8>`
    |
    = note: expected reference `&[_; 0]`
               found reference `&Vec<u8>`