File tree 3 files changed +28
-10
lines changed
src/test/ui/type/type-check
3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+ fn main() {
3
+ let mut v = Vec::new();
4
+ v.push(0i32);
5
+ //~^ NOTE this is of type `i32`, which makes `v` to be inferred as `Vec<i32>`
6
+ v.push(0);
7
+ v.push(1i32); //~ ERROR mismatched types
8
+ //~^ NOTE expected `i32`, found `u32`
9
+ //~| NOTE arguments to this function are incorrect
10
+ //~| NOTE associated function defined here
11
+ //~| HELP change the type of the numeric literal from `u32` to `i32`
12
+ }
Original file line number Diff line number Diff line change
1
+ // run-rustfix
1
2
fn main ( ) {
2
- let v = Vec :: new ( ) ;
3
+ let mut v = Vec :: new ( ) ;
4
+ v. push ( 0i32 ) ;
5
+ //~^ NOTE this is of type `i32`, which makes `v` to be inferred as `Vec<i32>`
3
6
v. push ( 0 ) ;
4
- //~^ NOTE this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
5
- v. push ( 0 ) ;
6
- v. push ( "" ) ; //~ ERROR mismatched types
7
- //~^ NOTE expected integer, found `&str`
7
+ v. push ( 1u32 ) ; //~ ERROR mismatched types
8
+ //~^ NOTE expected `i32`, found `u32`
8
9
//~| NOTE arguments to this function are incorrect
9
10
//~| NOTE associated function defined here
11
+ //~| HELP change the type of the numeric literal from `u32` to `i32`
10
12
}
Original file line number Diff line number Diff line change 1
1
error[E0308]: mismatched types
2
- --> $DIR/point-at-inference-3.rs:6 :12
2
+ --> $DIR/point-at-inference-3.rs:7 :12
3
3
|
4
- LL | v.push(0 );
5
- | - this is of type `{integer} `, which makes `v` to be inferred as `Vec<{integer} >`
4
+ LL | v.push(0i32 );
5
+ | ---- this is of type `i32 `, which makes `v` to be inferred as `Vec<i32 >`
6
6
...
7
- LL | v.push("" );
8
- | ---- ^^ expected integer , found `&str `
7
+ LL | v.push(1u32 );
8
+ | ---- ^^^^ expected `i32` , found `u32 `
9
9
| |
10
10
| arguments to this function are incorrect
11
11
|
12
12
note: associated function defined here
13
13
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
14
+ help: change the type of the numeric literal from `u32` to `i32`
15
+ |
16
+ LL | v.push(1i32);
17
+ | ~~~
14
18
15
19
error: aborting due to previous error
16
20
You can’t perform that action at this time.
0 commit comments