More accurate argument blames, add some comments

This commit is contained in:
Michael Goulet 2023-03-03 01:35:51 +00:00
parent 5a71029dd3
commit 5cc4757421
4 changed files with 69 additions and 25 deletions

View file

@ -11,9 +11,11 @@ fn main() {
let s = S(None);
s.infer(0i32);
//~^ ERROR this method takes 2 arguments but 1 argument was supplied
//~| NOTE here the type of `s` is inferred to be `S<i32, _>`
//~| NOTE this argument has type `i32`...
//~| NOTE ... which causes `s` to have type `S<i32, _>`
//~| NOTE an argument is missing
//~| HELP provide the argument
//~| HELP change the type of the numeric literal from `i32` to `u32`
let t: S<u32, _> = s;
//~^ ERROR mismatched types
//~| NOTE expected `S<u32, _>`, found `S<i32, _>`

View file

@ -15,10 +15,12 @@ LL | s.infer(0i32, /* b */);
| ~~~~~~~~~~~~~~~
error[E0308]: mismatched types
--> $DIR/point-at-inference-4.rs:17:24
--> $DIR/point-at-inference-4.rs:19:24
|
LL | s.infer(0i32);
| - here the type of `s` is inferred to be `S<i32, _>`
| - ---- this argument has type `i32`...
| |
| ... which causes `s` to have type `S<i32, _>`
...
LL | let t: S<u32, _> = s;
| --------- ^ expected `S<u32, _>`, found `S<i32, _>`
@ -27,6 +29,10 @@ LL | let t: S<u32, _> = s;
|
= note: expected struct `S<u32, _>`
found struct `S<i32, _>`
help: change the type of the numeric literal from `i32` to `u32`
|
LL | s.infer(0u32);
| ~~~
error: aborting due to 2 previous errors