about summary refs log tree commit diff
path: root/src/test/ui/issues
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2022-01-21 23:50:54 -0500
committerJack Huey <31162821+jackh726@users.noreply.github.com>2022-04-16 02:26:56 -0400
commitb6c87c555f3b664f558d137d5f7696a07488157e (patch)
tree573e046694217ea40ca8278ca1676bec16ac1819 /src/test/ui/issues
parente7575f9670f3c837def3d186ae09366c75c7632e (diff)
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.

The algorithm is inspired by Levenshtein distance and longest common sub-sequence.   In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.

We then modify that algorithm to detect 4 cases:

 - A function input is missing
 - An extra argument was provided
 - The type of an argument is straight up invalid
 - Two arguments have been swapped
 - A subset of the arguments have been shuffled

(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)

It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.

The basic sketch of the algorithm is as follows:

 - Construct a boolean grid, with a row for each argument, and a column for each input.  The cell [i, j] is true if the i'th argument could satisfy the j'th input.
 - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
 - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
 - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
 - Swapped / Permuted arguments are identified with a cycle detection algorithm.

As each issue is found, we remove the relevant inputs / arguments and check for more issues.  If we find no issues, we match up any "valid" arguments, and start again.

Note that there's a lot of extra complexity:
 - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
 - Closure arguments are wrapped in a tuple and need to be unwrapped
 - We need to resolve closure types after the rest, to allow the most specific type constraints
 - We need to handle imported C functions that might be variadic in their inputs.

I tried to document a lot of this in comments in the code and keep the naming clear.
Diffstat (limited to 'src/test/ui/issues')
-rw-r--r--src/test/ui/issues/issue-10764.stderr9
-rw-r--r--src/test/ui/issues/issue-11374.stderr14
-rw-r--r--src/test/ui/issues/issue-12997-2.stderr10
-rw-r--r--src/test/ui/issues/issue-13359.stderr22
-rw-r--r--src/test/ui/issues/issue-13853.stderr14
-rw-r--r--src/test/ui/issues/issue-1448-2.stderr9
-rw-r--r--src/test/ui/issues/issue-15783.stderr9
-rw-r--r--src/test/ui/issues/issue-16939.stderr8
-rw-r--r--src/test/ui/issues/issue-17033.stderr9
-rw-r--r--src/test/ui/issues/issue-18819.stderr17
-rw-r--r--src/test/ui/issues/issue-24819.stderr9
-rw-r--r--src/test/ui/issues/issue-26094.rs4
-rw-r--r--src/test/ui/issues/issue-26094.stderr8
-rw-r--r--src/test/ui/issues/issue-3044.rs3
-rw-r--r--src/test/ui/issues/issue-3044.stderr27
-rw-r--r--src/test/ui/issues/issue-43420-no-over-suggest.stderr9
-rw-r--r--src/test/ui/issues/issue-4517.stderr10
-rw-r--r--src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr30
-rw-r--r--src/test/ui/issues/issue-48364.stderr9
-rw-r--r--src/test/ui/issues/issue-4935.stderr8
-rw-r--r--src/test/ui/issues/issue-51154.stderr9
-rw-r--r--src/test/ui/issues/issue-5216.stderr9
-rw-r--r--src/test/ui/issues/issue-61106.stderr15
-rw-r--r--src/test/ui/issues/issue-69306.stderr45
24 files changed, 249 insertions, 67 deletions
diff --git a/src/test/ui/issues/issue-10764.stderr b/src/test/ui/issues/issue-10764.stderr
index b0bafc9942e..4d8a85a1397 100644
--- a/src/test/ui/issues/issue-10764.stderr
+++ b/src/test/ui/issues/issue-10764.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-10764.rs:4:15
    |
 LL | fn main() { f(bar) }
-   |               ^^^ expected "Rust" fn, found "C" fn
+   |             - ^^^ expected "Rust" fn, found "C" fn
+   |             |
+   |             arguments to this function are incorrect
    |
    = note: expected fn pointer `fn()`
                  found fn item `extern "C" fn() {bar}`
+note: function defined here
+  --> $DIR/issue-10764.rs:1:4
+   |
+LL | fn f(_: extern "Rust" fn()) {}
+   |    ^ ---------------------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-11374.stderr b/src/test/ui/issues/issue-11374.stderr
index d6a3e758de8..3a1d43310e2 100644
--- a/src/test/ui/issues/issue-11374.stderr
+++ b/src/test/ui/issues/issue-11374.stderr
@@ -2,13 +2,19 @@ error[E0308]: mismatched types
   --> $DIR/issue-11374.rs:26:15
    |
 LL |     c.read_to(v);
-   |               ^
-   |               |
-   |               expected `&mut [u8]`, found struct `Vec`
-   |               help: consider mutably borrowing here: `&mut v`
+   |       ------- ^
+   |       |       |
+   |       |       expected `&mut [u8]`, found struct `Vec`
+   |       |       help: consider mutably borrowing here: `&mut v`
+   |       arguments to this function are incorrect
    |
    = note: expected mutable reference `&mut [u8]`
                          found struct `Vec<_>`
+note: associated function defined here
+  --> $DIR/issue-11374.rs:13:12
+   |
+LL |     pub fn read_to(&mut self, vec: &mut [u8]) {
+   |            ^^^^^^^ ---------  --------------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-12997-2.stderr b/src/test/ui/issues/issue-12997-2.stderr
index 3b89e8bc451..2a3d0e3457b 100644
--- a/src/test/ui/issues/issue-12997-2.stderr
+++ b/src/test/ui/issues/issue-12997-2.stderr
@@ -4,8 +4,16 @@ error[E0308]: mismatched types
 LL | #[bench]
    | -------- in this procedural macro expansion
 LL | fn bar(x: isize) { }
-   | ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `&mut Bencher`
+   | ^^^^^^^^^^^^^^^^^^^^
+   | |
+   | expected `isize`, found `&mut Bencher`
+   | arguments to this function are incorrect
    |
+note: function defined here
+  --> $DIR/issue-12997-2.rs:8:4
+   |
+LL | fn bar(x: isize) { }
+   |    ^^^ --------
    = note: this error originates in the attribute macro `bench` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-13359.stderr b/src/test/ui/issues/issue-13359.stderr
index 075c92e65de..db6283ea11f 100644
--- a/src/test/ui/issues/issue-13359.stderr
+++ b/src/test/ui/issues/issue-13359.stderr
@@ -2,23 +2,29 @@ error[E0308]: mismatched types
   --> $DIR/issue-13359.rs:6:9
    |
 LL |     foo(1*(1 as isize));
-   |         ^^^^^^^^^^^^^^ expected `i16`, found `isize`
+   |     --- ^^^^^^^^^^^^^^ expected `i16`, found `isize`
+   |     |
+   |     arguments to this function are incorrect
    |
-help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit
+note: function defined here
+  --> $DIR/issue-13359.rs:1:4
    |
-LL |     foo((1*(1 as isize)).try_into().unwrap());
-   |         +              +++++++++++++++++++++
+LL | fn foo(_s: i16) { }
+   |    ^^^ -------
 
 error[E0308]: mismatched types
   --> $DIR/issue-13359.rs:10:9
    |
 LL |     bar(1*(1 as usize));
-   |         ^^^^^^^^^^^^^^ expected `u32`, found `usize`
+   |     --- ^^^^^^^^^^^^^^ expected `u32`, found `usize`
+   |     |
+   |     arguments to this function are incorrect
    |
-help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
+note: function defined here
+  --> $DIR/issue-13359.rs:3:4
    |
-LL |     bar((1*(1 as usize)).try_into().unwrap());
-   |         +              +++++++++++++++++++++
+LL | fn bar(_s: u32) { }
+   |    ^^^ -------
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr
index 527e0225eb9..657bda5f62b 100644
--- a/src/test/ui/issues/issue-13853.stderr
+++ b/src/test/ui/issues/issue-13853.stderr
@@ -20,13 +20,19 @@ error[E0308]: mismatched types
   --> $DIR/issue-13853.rs:37:13
    |
 LL |     iterate(graph);
-   |             ^^^^^
-   |             |
-   |             expected reference, found struct `Vec`
-   |             help: consider borrowing here: `&graph`
+   |     ------- ^^^^^
+   |     |       |
+   |     |       expected reference, found struct `Vec`
+   |     |       help: consider borrowing here: `&graph`
+   |     arguments to this function are incorrect
    |
    = note: expected reference `&_`
                  found struct `Vec<Stuff>`
+note: function defined here
+  --> $DIR/issue-13853.rs:26:4
+   |
+LL | fn iterate<N: Node, G: Graph<N>>(graph: &G) {
+   |    ^^^^^^^                       ---------
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/issues/issue-1448-2.stderr b/src/test/ui/issues/issue-1448-2.stderr
index da44566d075..203dd92c9fb 100644
--- a/src/test/ui/issues/issue-1448-2.stderr
+++ b/src/test/ui/issues/issue-1448-2.stderr
@@ -2,8 +2,15 @@ error[E0308]: mismatched types
   --> $DIR/issue-1448-2.rs:6:24
    |
 LL |     println!("{}", foo(10i32));
-   |                        ^^^^^ expected `u32`, found `i32`
+   |                    --- ^^^^^ expected `u32`, found `i32`
+   |                    |
+   |                    arguments to this function are incorrect
    |
+note: function defined here
+  --> $DIR/issue-1448-2.rs:3:4
+   |
+LL | fn foo(a: u32) -> u32 { a }
+   |    ^^^ ------
 help: change the type of the numeric literal from `i32` to `u32`
    |
 LL |     println!("{}", foo(10u32));
diff --git a/src/test/ui/issues/issue-15783.stderr b/src/test/ui/issues/issue-15783.stderr
index 0b09751676e..660dfe9ed3d 100644
--- a/src/test/ui/issues/issue-15783.stderr
+++ b/src/test/ui/issues/issue-15783.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-15783.rs:8:19
    |
 LL |     let msg = foo(x);
-   |                   ^ expected slice `[&str]`, found array `[&str; 1]`
+   |               --- ^ expected slice `[&str]`, found array `[&str; 1]`
+   |               |
+   |               arguments to this function are incorrect
    |
    = note: expected enum `Option<&[&str]>`
               found enum `Option<&[&str; 1]>`
+note: function defined here
+  --> $DIR/issue-15783.rs:1:8
+   |
+LL | pub fn foo(params: Option<&[&str]>) -> usize {
+   |        ^^^ -----------------------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-16939.stderr b/src/test/ui/issues/issue-16939.stderr
index 8e4237039fa..294524f0b61 100644
--- a/src/test/ui/issues/issue-16939.stderr
+++ b/src/test/ui/issues/issue-16939.stderr
@@ -2,15 +2,17 @@ error[E0057]: this function takes 0 arguments but 1 argument was supplied
   --> $DIR/issue-16939.rs:5:9
    |
 LL |     |t| f(t);
-   |         ^ - supplied 1 argument
-   |         |
-   |         expected 0 arguments
+   |         ^ - argument unexpected
    |
 note: associated function defined here
   --> $SRC_DIR/core/src/ops/function.rs:LL:COL
    |
 LL |     extern "rust-call" fn call(&self, args: Args) -> Self::Output;
    |                           ^^^^
+help: remove the extra argument
+   |
+LL |     |t| f();
+   |         ~~~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-17033.stderr b/src/test/ui/issues/issue-17033.stderr
index 518fc30142c..f26bee5ff45 100644
--- a/src/test/ui/issues/issue-17033.stderr
+++ b/src/test/ui/issues/issue-17033.stderr
@@ -2,10 +2,11 @@ error[E0308]: mismatched types
   --> $DIR/issue-17033.rs:2:10
    |
 LL |     (*p)(())
-   |          ^^
-   |          |
-   |          expected `&mut ()`, found `()`
-   |          help: consider mutably borrowing here: `&mut ()`
+   |     ---- ^^
+   |     |    |
+   |     |    expected `&mut ()`, found `()`
+   |     |    help: consider mutably borrowing here: `&mut ()`
+   |     arguments to this function are incorrect
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-18819.stderr b/src/test/ui/issues/issue-18819.stderr
index b10d26abe34..db228fded6e 100644
--- a/src/test/ui/issues/issue-18819.stderr
+++ b/src/test/ui/issues/issue-18819.stderr
@@ -2,15 +2,26 @@ error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> $DIR/issue-18819.rs:16:5
    |
 LL |     print_x(X);
-   |     ^^^^^^^ - supplied 1 argument
-   |     |
-   |     expected 2 arguments
+   |     ^^^^^^^---
+   |            ||
+   |            |expected reference, found struct `X`
+   |            an argument of type `&str` is missing
    |
+   = note: expected reference `&dyn Foo<Item = bool>`
+                 found struct `X`
 note: function defined here
   --> $DIR/issue-18819.rs:11:4
    |
 LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
    |    ^^^^^^^ ----------------------  -----------
+help: consider borrowing here
+   |
+LL |     print_x(&X);
+   |             ~~
+help: provide the argument
+   |
+LL |     print_x({&dyn Foo<Item = bool>}, {&str});
+   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-24819.stderr b/src/test/ui/issues/issue-24819.stderr
index 2f931e59d59..982a11fef80 100644
--- a/src/test/ui/issues/issue-24819.stderr
+++ b/src/test/ui/issues/issue-24819.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-24819.rs:5:9
    |
 LL |     foo(&mut v);
-   |         ^^^^^^ expected struct `HashSet`, found struct `Vec`
+   |     --- ^^^^^^ expected struct `HashSet`, found struct `Vec`
+   |     |
+   |     arguments to this function are incorrect
    |
    = note: expected mutable reference `&mut HashSet<u32>`
               found mutable reference `&mut Vec<_>`
+note: function defined here
+  --> $DIR/issue-24819.rs:10:4
+   |
+LL | fn foo(h: &mut HashSet<u32>) {
+   |    ^^^ --------------------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-26094.rs b/src/test/ui/issues/issue-26094.rs
index 78fb0491d82..981c3abb4ba 100644
--- a/src/test/ui/issues/issue-26094.rs
+++ b/src/test/ui/issues/issue-26094.rs
@@ -1,6 +1,6 @@
 macro_rules! some_macro {
     ($other: expr) => ({
-        $other(None) //~ NOTE supplied 1 argument
+        $other(None) //~ NOTE argument unexpected
     })
 }
 
@@ -9,5 +9,5 @@ fn some_function() {} //~ NOTE defined here
 fn main() {
     some_macro!(some_function);
     //~^ ERROR this function takes 0 arguments but 1 argument was supplied
-    //~| NOTE expected 0 arguments
+    //~| NOTE in this expansion of some_macro!
 }
diff --git a/src/test/ui/issues/issue-26094.stderr b/src/test/ui/issues/issue-26094.stderr
index a6f1ac9286c..1013518e1da 100644
--- a/src/test/ui/issues/issue-26094.stderr
+++ b/src/test/ui/issues/issue-26094.stderr
@@ -2,16 +2,20 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
   --> $DIR/issue-26094.rs:10:17
    |
 LL |         $other(None)
-   |                ---- supplied 1 argument
+   |                ---- argument unexpected
 ...
 LL |     some_macro!(some_function);
-   |                 ^^^^^^^^^^^^^ expected 0 arguments
+   |                 ^^^^^^^^^^^^^
    |
 note: function defined here
   --> $DIR/issue-26094.rs:7:4
    |
 LL | fn some_function() {}
    |    ^^^^^^^^^^^^^
+help: remove the extra argument
+   |
+LL |         some_function()
+   |         ~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-3044.rs b/src/test/ui/issues/issue-3044.rs
index 81d76a90eb0..7363cae8370 100644
--- a/src/test/ui/issues/issue-3044.rs
+++ b/src/test/ui/issues/issue-3044.rs
@@ -2,5 +2,6 @@ fn main() {
     let needlesArr: Vec<char> = vec!['a', 'f'];
     needlesArr.iter().fold(|x, y| {
     });
-    //~^^ ERROR this function takes 2 arguments but 1 argument was supplied
+    //~^^ ERROR mismatched types
+    //~| ERROR this function takes 2 arguments but 1 argument was supplied
 }
diff --git a/src/test/ui/issues/issue-3044.stderr b/src/test/ui/issues/issue-3044.stderr
index b93aeade95e..5bb07cfda21 100644
--- a/src/test/ui/issues/issue-3044.stderr
+++ b/src/test/ui/issues/issue-3044.stderr
@@ -1,19 +1,34 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-3044.rs:3:35
+   |
+LL |       needlesArr.iter().fold(|x, y| {
+   |  ___________________________________^
+LL | |     });
+   | |_____^ expected closure, found `()`
+   |
+   = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 4:6]`
+            found unit type `()`
+
 error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> $DIR/issue-3044.rs:3:23
    |
 LL |       needlesArr.iter().fold(|x, y| {
-   |  _______________________^^^^_-
-   | |                       |
-   | |                       expected 2 arguments
+   |  _______________________^^^^-
 LL | |     });
-   | |_____- supplied 1 argument
+   | |______- an argument is missing
    |
 note: associated function defined here
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
    |
 LL |     fn fold<B, F>(mut self, init: B, mut f: F) -> B
    |        ^^^^
+help: provide the argument
+   |
+LL ~     needlesArr.iter().fold(|x, y| {
+LL ~     }, {_});
+   |
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0061`.
+Some errors have detailed explanations: E0061, E0308.
+For more information about an error, try `rustc --explain E0061`.
diff --git a/src/test/ui/issues/issue-43420-no-over-suggest.stderr b/src/test/ui/issues/issue-43420-no-over-suggest.stderr
index 77d52f6ecab..58fd1121a6b 100644
--- a/src/test/ui/issues/issue-43420-no-over-suggest.stderr
+++ b/src/test/ui/issues/issue-43420-no-over-suggest.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-43420-no-over-suggest.rs:8:9
    |
 LL |     foo(&a);
-   |         ^^ expected slice `[u16]`, found struct `Vec`
+   |     --- ^^ expected slice `[u16]`, found struct `Vec`
+   |     |
+   |     arguments to this function are incorrect
    |
    = note: expected reference `&[u16]`
               found reference `&Vec<u8>`
+note: function defined here
+  --> $DIR/issue-43420-no-over-suggest.rs:4:4
+   |
+LL | fn foo(b: &[u16]) {}
+   |    ^^^ ---------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-4517.stderr b/src/test/ui/issues/issue-4517.stderr
index 1ae97b69c6c..70b4ca5ec49 100644
--- a/src/test/ui/issues/issue-4517.stderr
+++ b/src/test/ui/issues/issue-4517.stderr
@@ -2,7 +2,15 @@ error[E0308]: mismatched types
   --> $DIR/issue-4517.rs:5:9
    |
 LL |     bar(foo);
-   |         ^^^ expected `usize`, found array `[u8; 4]`
+   |     --- ^^^ expected `usize`, found array `[u8; 4]`
+   |     |
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/issue-4517.rs:1:4
+   |
+LL | fn bar(int_param: usize) {}
+   |    ^^^ ----------------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr
index 2d666e2b66c..e874ded8ec5 100644
--- a/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr
+++ b/src/test/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr
@@ -2,19 +2,33 @@ error[E0308]: mismatched types
   --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:42
    |
 LL |     light_flows_our_war_of_mocking_words(behold as usize);
-   |                                          ^^^^^^^^^^^^^^^
-   |                                          |
-   |                                          expected `&usize`, found `usize`
-   |                                          help: consider borrowing here: `&(behold as usize)`
+   |     ------------------------------------ ^^^^^^^^^^^^^^^
+   |     |                                    |
+   |     |                                    expected `&usize`, found `usize`
+   |     |                                    help: consider borrowing here: `&(behold as usize)`
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:5:4
+   |
+LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
+   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
 
 error[E0308]: mismatched types
   --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42
    |
 LL |     light_flows_our_war_of_mocking_words(with_tears + 4);
-   |                                          ^^^^^^^^^^^^^^
-   |                                          |
-   |                                          expected `&usize`, found `usize`
-   |                                          help: consider borrowing here: `&(with_tears + 4)`
+   |     ------------------------------------ ^^^^^^^^^^^^^^
+   |     |                                    |
+   |     |                                    expected `&usize`, found `usize`
+   |     |                                    help: consider borrowing here: `&(with_tears + 4)`
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:5:4
+   |
+LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
+   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-48364.stderr b/src/test/ui/issues/issue-48364.stderr
index 37a42d2382d..7fd36676df8 100644
--- a/src/test/ui/issues/issue-48364.stderr
+++ b/src/test/ui/issues/issue-48364.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-48364.rs:2:21
    |
 LL |     b"".starts_with(stringify!(foo))
-   |                     ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str`
+   |         ----------- ^^^^^^^^^^^^^^^ expected slice `[u8]`, found `str`
+   |         |
+   |         arguments to this function are incorrect
    |
    = note: expected reference `&[u8]`
               found reference `&'static str`
+note: associated function defined here
+  --> $SRC_DIR/core/src/slice/mod.rs:LL:COL
+   |
+LL |     pub fn starts_with(&self, needle: &[T]) -> bool
+   |            ^^^^^^^^^^^
    = note: this error originates in the macro `stringify` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-4935.stderr b/src/test/ui/issues/issue-4935.stderr
index 03b9b91edef..b4cebe2a68b 100644
--- a/src/test/ui/issues/issue-4935.stderr
+++ b/src/test/ui/issues/issue-4935.stderr
@@ -2,15 +2,17 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
   --> $DIR/issue-4935.rs:5:13
    |
 LL | fn main() { foo(5, 6) }
-   |             ^^^ -  - supplied 2 arguments
-   |             |
-   |             expected 1 argument
+   |             ^^^    - argument unexpected
    |
 note: function defined here
   --> $DIR/issue-4935.rs:3:4
    |
 LL | fn foo(a: usize) {}
    |    ^^^ --------
+help: remove the extra argument
+   |
+LL | fn main() { foo(5) }
+   |             ~~~~~~
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-51154.stderr b/src/test/ui/issues/issue-51154.stderr
index 3c3428f3096..f2cbc3e6feb 100644
--- a/src/test/ui/issues/issue-51154.stderr
+++ b/src/test/ui/issues/issue-51154.stderr
@@ -4,11 +4,18 @@ error[E0308]: mismatched types
 LL | fn foo<F: FnMut()>() {
    |        - this type parameter
 LL |     let _: Box<F> = Box::new(|| ());
-   |                              ^^^^^ expected type parameter `F`, found closure
+   |                     -------- ^^^^^ expected type parameter `F`, found closure
+   |                     |
+   |                     arguments to this function are incorrect
    |
    = note: expected type parameter `F`
                      found closure `[closure@$DIR/issue-51154.rs:2:30: 2:35]`
    = help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F`
+note: associated function defined here
+  --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
+   |
+LL |     pub fn new(x: T) -> Self {
+   |            ^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-5216.stderr b/src/test/ui/issues/issue-5216.stderr
index 29c95e4fb62..1afff28f0b4 100644
--- a/src/test/ui/issues/issue-5216.stderr
+++ b/src/test/ui/issues/issue-5216.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-5216.rs:3:21
    |
 LL | pub static C: S = S(f);
-   |                     ^ expected struct `Box`, found fn item
+   |                   - ^ expected struct `Box`, found fn item
+   |                   |
+   |                   arguments to this struct are incorrect
    |
    = note: expected struct `Box<(dyn FnMut() + Sync + 'static)>`
              found fn item `fn() {f}`
+note: tuple struct defined here
+  --> $DIR/issue-5216.rs:2:8
+   |
+LL | struct S(Box<dyn FnMut() + Sync>);
+   |        ^
 
 error[E0308]: mismatched types
   --> $DIR/issue-5216.rs:8:19
diff --git a/src/test/ui/issues/issue-61106.stderr b/src/test/ui/issues/issue-61106.stderr
index 2d841d28ee2..2bc09234116 100644
--- a/src/test/ui/issues/issue-61106.stderr
+++ b/src/test/ui/issues/issue-61106.stderr
@@ -2,10 +2,17 @@ error[E0308]: mismatched types
   --> $DIR/issue-61106.rs:3:9
    |
 LL |     foo(x.clone());
-   |         ^^^^^^^^^
-   |         |
-   |         expected `&str`, found struct `String`
-   |         help: consider borrowing here: `&x`
+   |     --- ^^^^^^^^^
+   |     |   |
+   |     |   expected `&str`, found struct `String`
+   |     |   help: consider borrowing here: `&x`
+   |     arguments to this function are incorrect
+   |
+note: function defined here
+  --> $DIR/issue-61106.rs:6:4
+   |
+LL | fn foo(_: &str) {}
+   |    ^^^ -------
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-69306.stderr b/src/test/ui/issues/issue-69306.stderr
index 58e85ec700d..61ec5d3180c 100644
--- a/src/test/ui/issues/issue-69306.stderr
+++ b/src/test/ui/issues/issue-69306.stderr
@@ -4,10 +4,17 @@ error[E0308]: mismatched types
 LL | impl<T> S0<T> {
    |      - this type parameter
 LL |     const C: S0<u8> = Self(0);
-   |                            ^ expected type parameter `T`, found integer
+   |                       ---- ^ expected type parameter `T`, found integer
+   |                       |
+   |                       arguments to this function are incorrect
    |
    = note: expected type parameter `T`
                         found type `{integer}`
+note: tuple struct defined here
+  --> $DIR/issue-69306.rs:3:8
+   |
+LL | struct S0<T>(T);
+   |        ^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:5:23
@@ -27,10 +34,17 @@ LL | impl<T> S0<T> {
    |      - this type parameter
 ...
 LL |         Self(0);
-   |              ^ expected type parameter `T`, found integer
+   |         ---- ^ expected type parameter `T`, found integer
+   |         |
+   |         arguments to this function are incorrect
    |
    = note: expected type parameter `T`
                         found type `{integer}`
+note: tuple struct defined here
+  --> $DIR/issue-69306.rs:3:8
+   |
+LL | struct S0<T>(T);
+   |        ^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:27:14
@@ -39,10 +53,17 @@ LL | impl<T> Foo<T> for <S0<T> as Fun>::Out {
    |      - this type parameter
 LL |     fn foo() {
 LL |         Self(0);
-   |              ^ expected type parameter `T`, found integer
+   |         ---- ^ expected type parameter `T`, found integer
+   |         |
+   |         arguments to this function are incorrect
    |
    = note: expected type parameter `T`
                         found type `{integer}`
+note: tuple struct defined here
+  --> $DIR/issue-69306.rs:3:8
+   |
+LL | struct S0<T>(T);
+   |        ^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:33:32
@@ -50,10 +71,17 @@ error[E0308]: mismatched types
 LL | impl<T> S1<T, u8> {
    |      - this type parameter
 LL |     const C: S1<u8, u8> = Self(0, 1);
-   |                                ^ expected type parameter `T`, found integer
+   |                           ---- ^ expected type parameter `T`, found integer
+   |                           |
+   |                           arguments to this function are incorrect
    |
    = note: expected type parameter `T`
                         found type `{integer}`
+note: tuple struct defined here
+  --> $DIR/issue-69306.rs:31:8
+   |
+LL | struct S1<T, U>(T, U);
+   |        ^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:33:27
@@ -74,12 +102,19 @@ LL | impl<T> S2<T> {
 LL |     fn map<U>(x: U) -> S2<U> {
    |            - found type parameter
 LL |         Self(x)
-   |              ^ expected type parameter `T`, found type parameter `U`
+   |         ---- ^ expected type parameter `T`, found type parameter `U`
+   |         |
+   |         arguments to this function are incorrect
    |
    = note: expected type parameter `T`
               found type parameter `U`
    = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
    = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
+note: tuple struct defined here
+  --> $DIR/issue-69306.rs:38:8
+   |
+LL | struct S2<T>(T);
+   |        ^^
 
 error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:41:9