about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-08-13 05:22:47 +0000
committerMichael Goulet <michael@errs.io>2022-08-13 18:24:36 +0000
commitb0cd1e192c2e217c08f2759d86a3807acb8e2178 (patch)
tree6797146a5570856ab0dbc4457b40890bd2f4d246
parent75b7e52e92c3b00fc891b47f5b2efdff0a2be55a (diff)
Label argument coercion errors
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt/checks.rs4
-rw-r--r--src/test/ui/argument-suggestions/issue-96638.stderr4
-rw-r--r--src/test/ui/argument-suggestions/issue-97484.stderr5
3 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
index 1d1f755947f..11f11d8c612 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
@@ -545,7 +545,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty);
             let can_coerce = self.can_coerce(arg_ty, coerced_ty);
             if !can_coerce {
-                return Compatibility::Incompatible(None);
+                return Compatibility::Incompatible(Some(ty::error::TypeError::Sorts(
+                    ty::error::ExpectedFound::new(true, coerced_ty, arg_ty),
+                )));
             }
 
             // Using probe here, since we don't want this subtyping to affect inference.
diff --git a/src/test/ui/argument-suggestions/issue-96638.stderr b/src/test/ui/argument-suggestions/issue-96638.stderr
index 8af31b8b751..804cb1aa322 100644
--- a/src/test/ui/argument-suggestions/issue-96638.stderr
+++ b/src/test/ui/argument-suggestions/issue-96638.stderr
@@ -2,7 +2,9 @@ error[E0061]: this function takes 3 arguments but 2 arguments were supplied
   --> $DIR/issue-96638.rs:8:5
    |
 LL |     f(&x, "");
-   |     ^ -- an argument of type `usize` is missing
+   |     ^ --  -- expected `usize`, found `&str`
+   |       |
+   |       an argument of type `usize` is missing
    |
 note: function defined here
   --> $DIR/issue-96638.rs:1:4
diff --git a/src/test/ui/argument-suggestions/issue-97484.stderr b/src/test/ui/argument-suggestions/issue-97484.stderr
index 9589e919c0a..b5dedf0f4fa 100644
--- a/src/test/ui/argument-suggestions/issue-97484.stderr
+++ b/src/test/ui/argument-suggestions/issue-97484.stderr
@@ -2,8 +2,9 @@ error[E0061]: this function takes 4 arguments but 7 arguments were supplied
   --> $DIR/issue-97484.rs:12:5
    |
 LL |     foo(&&A, B, C, D, E, F, G);
-   |     ^^^      -  -        - argument of type `F` unexpected
-   |              |  |
+   |     ^^^      -  -     -  - argument of type `F` unexpected
+   |              |  |     |
+   |              |  |     expected `&E`, found struct `E`
    |              |  argument of type `C` unexpected
    |              argument of type `B` unexpected
    |