Suggest changing argument on type error
This commit is contained in:
parent
c905f5e1b0
commit
f571862d17
12
src/test/ui/type/type-check/point-at-inference-3.fixed
Normal file
12
src/test/ui/type/type-check/point-at-inference-3.fixed
Normal file
@ -0,0 +1,12 @@
|
||||
// run-rustfix
|
||||
fn main() {
|
||||
let mut v = Vec::new();
|
||||
v.push(0i32);
|
||||
//~^ NOTE this is of type `i32`, which makes `v` to be inferred as `Vec<i32>`
|
||||
v.push(0);
|
||||
v.push(1i32); //~ ERROR mismatched types
|
||||
//~^ NOTE expected `i32`, found `u32`
|
||||
//~| NOTE arguments to this function are incorrect
|
||||
//~| NOTE associated function defined here
|
||||
//~| HELP change the type of the numeric literal from `u32` to `i32`
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
// run-rustfix
|
||||
fn main() {
|
||||
let v = Vec::new();
|
||||
let mut v = Vec::new();
|
||||
v.push(0i32);
|
||||
//~^ NOTE this is of type `i32`, which makes `v` to be inferred as `Vec<i32>`
|
||||
v.push(0);
|
||||
//~^ NOTE this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
|
||||
v.push(0);
|
||||
v.push(""); //~ ERROR mismatched types
|
||||
//~^ NOTE expected integer, found `&str`
|
||||
v.push(1u32); //~ ERROR mismatched types
|
||||
//~^ NOTE expected `i32`, found `u32`
|
||||
//~| NOTE arguments to this function are incorrect
|
||||
//~| NOTE associated function defined here
|
||||
//~| HELP change the type of the numeric literal from `u32` to `i32`
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-at-inference-3.rs:6:12
|
||||
--> $DIR/point-at-inference-3.rs:7:12
|
||||
|
|
||||
LL | v.push(0);
|
||||
| - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
|
||||
LL | v.push(0i32);
|
||||
| ---- this is of type `i32`, which makes `v` to be inferred as `Vec<i32>`
|
||||
...
|
||||
LL | v.push("");
|
||||
| ---- ^^ expected integer, found `&str`
|
||||
LL | v.push(1u32);
|
||||
| ---- ^^^^ expected `i32`, found `u32`
|
||||
| |
|
||||
| arguments to this function are incorrect
|
||||
|
|
||||
note: associated function defined here
|
||||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
||||
help: change the type of the numeric literal from `u32` to `i32`
|
||||
|
|
||||
LL | v.push(1i32);
|
||||
| ~~~
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user