Skip to content

Commit b0cd1e1

Browse files
Label argument coercion errors
1 parent 75b7e52 commit b0cd1e1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
545545
let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty);
546546
let can_coerce = self.can_coerce(arg_ty, coerced_ty);
547547
if !can_coerce {
548-
return Compatibility::Incompatible(None);
548+
return Compatibility::Incompatible(Some(ty::error::TypeError::Sorts(
549+
ty::error::ExpectedFound::new(true, coerced_ty, arg_ty),
550+
)));
549551
}
550552

551553
// Using probe here, since we don't want this subtyping to affect inference.

src/test/ui/argument-suggestions/issue-96638.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0061]: this function takes 3 arguments but 2 arguments were supplied
22
--> $DIR/issue-96638.rs:8:5
33
|
44
LL | f(&x, "");
5-
| ^ -- an argument of type `usize` is missing
5+
| ^ -- -- expected `usize`, found `&str`
6+
| |
7+
| an argument of type `usize` is missing
68
|
79
note: function defined here
810
--> $DIR/issue-96638.rs:1:4

src/test/ui/argument-suggestions/issue-97484.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ error[E0061]: this function takes 4 arguments but 7 arguments were supplied
22
--> $DIR/issue-97484.rs:12:5
33
|
44
LL | foo(&&A, B, C, D, E, F, G);
5-
| ^^^ - - - argument of type `F` unexpected
6-
| | |
5+
| ^^^ - - - - argument of type `F` unexpected
6+
| | | |
7+
| | | expected `&E`, found struct `E`
78
| | argument of type `C` unexpected
89
| argument of type `B` unexpected
910
|

0 commit comments

Comments
 (0)