Skip to content

Commit a6033e3

Browse files
committed
Fix numeric-cast tests for new into suggestion
Remove `integer-into.rs` since the numeric-cast tests already cover these cases.
1 parent 57dd22b commit a6033e3

File tree

5 files changed

+43
-123
lines changed

5 files changed

+43
-123
lines changed

src/test/ui/numeric/numeric-cast-2.stderr

+8-14
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@ error[E0308]: mismatched types
1515
--> $DIR/numeric-cast-2.rs:7:18
1616
|
1717
LL | let y: i64 = x + x;
18-
| --- ^^^^^ expected `i64`, found `u16`
19-
| |
18+
| --- ^^^^^
19+
| | |
20+
| | expected `i64`, found `u16`
21+
| | help: you can convert an `u16` to `i64`: `(x + x).into()`
2022
| expected due to this
21-
|
22-
help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit
23-
|
24-
LL | let y: i64 = (x + x).try_into().unwrap();
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2623

2724
error[E0308]: mismatched types
2825
--> $DIR/numeric-cast-2.rs:9:18
2926
|
3027
LL | let z: i32 = x + x;
31-
| --- ^^^^^ expected `i32`, found `u16`
32-
| |
28+
| --- ^^^^^
29+
| | |
30+
| | expected `i32`, found `u16`
31+
| | help: you can convert an `u16` to `i32`: `(x + x).into()`
3332
| expected due to this
34-
|
35-
help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit
36-
|
37-
LL | let z: i32 = (x + x).try_into().unwrap();
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3933

4034
error: aborting due to 3 previous errors
4135

src/test/ui/numeric/numeric-cast.fixed

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn main() {
4949
//~^ ERROR mismatched types
5050
foo::<isize>(x_u16.try_into().unwrap());
5151
//~^ ERROR mismatched types
52-
foo::<isize>(x_u8.try_into().unwrap());
52+
foo::<isize>(x_u8.into());
5353
//~^ ERROR mismatched types
5454
foo::<isize>(x_isize);
5555
foo::<isize>(x_i64.try_into().unwrap());
@@ -89,11 +89,11 @@ fn main() {
8989
//~^ ERROR mismatched types
9090
foo::<i64>(x_u64.try_into().unwrap());
9191
//~^ ERROR mismatched types
92-
foo::<i64>(x_u32.try_into().unwrap());
92+
foo::<i64>(x_u32.into());
9393
//~^ ERROR mismatched types
94-
foo::<i64>(x_u16.try_into().unwrap());
94+
foo::<i64>(x_u16.into());
9595
//~^ ERROR mismatched types
96-
foo::<i64>(x_u8.try_into().unwrap());
96+
foo::<i64>(x_u8.into());
9797
//~^ ERROR mismatched types
9898
foo::<i64>(x_isize.try_into().unwrap());
9999
//~^ ERROR mismatched types
@@ -135,9 +135,9 @@ fn main() {
135135
//~^ ERROR mismatched types
136136
foo::<i32>(x_u32.try_into().unwrap());
137137
//~^ ERROR mismatched types
138-
foo::<i32>(x_u16.try_into().unwrap());
138+
foo::<i32>(x_u16.into());
139139
//~^ ERROR mismatched types
140-
foo::<i32>(x_u8.try_into().unwrap());
140+
foo::<i32>(x_u8.into());
141141
//~^ ERROR mismatched types
142142
foo::<i32>(x_isize.try_into().unwrap());
143143
//~^ ERROR mismatched types
@@ -181,7 +181,7 @@ fn main() {
181181
//~^ ERROR mismatched types
182182
foo::<i16>(x_u16.try_into().unwrap());
183183
//~^ ERROR mismatched types
184-
foo::<i16>(x_u8.try_into().unwrap());
184+
foo::<i16>(x_u8.into());
185185
//~^ ERROR mismatched types
186186
foo::<i16>(x_isize.try_into().unwrap());
187187
//~^ ERROR mismatched types

src/test/ui/numeric/numeric-cast.stderr

+28-42
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,10 @@ error[E0308]: mismatched types
141141
--> $DIR/numeric-cast.rs:52:18
142142
|
143143
LL | foo::<isize>(x_u8);
144-
| ^^^^ expected `isize`, found `u8`
145-
|
146-
help: you can convert an `u8` to `isize` and panic if the converted value wouldn't fit
147-
|
148-
LL | foo::<isize>(x_u8.try_into().unwrap());
149-
| ^^^^^^^^^^^^^^^^^^^^^^^^
144+
| ^^^^
145+
| |
146+
| expected `isize`, found `u8`
147+
| help: you can convert an `u8` to `isize`: `x_u8.into()`
150148

151149
error[E0308]: mismatched types
152150
--> $DIR/numeric-cast.rs:55:18
@@ -307,34 +305,28 @@ error[E0308]: mismatched types
307305
--> $DIR/numeric-cast.rs:92:16
308306
|
309307
LL | foo::<i64>(x_u32);
310-
| ^^^^^ expected `i64`, found `u32`
311-
|
312-
help: you can convert an `u32` to `i64` and panic if the converted value wouldn't fit
313-
|
314-
LL | foo::<i64>(x_u32.try_into().unwrap());
315-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
308+
| ^^^^^
309+
| |
310+
| expected `i64`, found `u32`
311+
| help: you can convert an `u32` to `i64`: `x_u32.into()`
316312

317313
error[E0308]: mismatched types
318314
--> $DIR/numeric-cast.rs:94:16
319315
|
320316
LL | foo::<i64>(x_u16);
321-
| ^^^^^ expected `i64`, found `u16`
322-
|
323-
help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit
324-
|
325-
LL | foo::<i64>(x_u16.try_into().unwrap());
326-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
317+
| ^^^^^
318+
| |
319+
| expected `i64`, found `u16`
320+
| help: you can convert an `u16` to `i64`: `x_u16.into()`
327321

328322
error[E0308]: mismatched types
329323
--> $DIR/numeric-cast.rs:96:16
330324
|
331325
LL | foo::<i64>(x_u8);
332-
| ^^^^ expected `i64`, found `u8`
333-
|
334-
help: you can convert an `u8` to `i64` and panic if the converted value wouldn't fit
335-
|
336-
LL | foo::<i64>(x_u8.try_into().unwrap());
337-
| ^^^^^^^^^^^^^^^^^^^^^^^^
326+
| ^^^^
327+
| |
328+
| expected `i64`, found `u8`
329+
| help: you can convert an `u8` to `i64`: `x_u8.into()`
338330

339331
error[E0308]: mismatched types
340332
--> $DIR/numeric-cast.rs:98:16
@@ -506,23 +498,19 @@ error[E0308]: mismatched types
506498
--> $DIR/numeric-cast.rs:138:16
507499
|
508500
LL | foo::<i32>(x_u16);
509-
| ^^^^^ expected `i32`, found `u16`
510-
|
511-
help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit
512-
|
513-
LL | foo::<i32>(x_u16.try_into().unwrap());
514-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
501+
| ^^^^^
502+
| |
503+
| expected `i32`, found `u16`
504+
| help: you can convert an `u16` to `i32`: `x_u16.into()`
515505

516506
error[E0308]: mismatched types
517507
--> $DIR/numeric-cast.rs:140:16
518508
|
519509
LL | foo::<i32>(x_u8);
520-
| ^^^^ expected `i32`, found `u8`
521-
|
522-
help: you can convert an `u8` to `i32` and panic if the converted value wouldn't fit
523-
|
524-
LL | foo::<i32>(x_u8.try_into().unwrap());
525-
| ^^^^^^^^^^^^^^^^^^^^^^^^
510+
| ^^^^
511+
| |
512+
| expected `i32`, found `u8`
513+
| help: you can convert an `u8` to `i32`: `x_u8.into()`
526514

527515
error[E0308]: mismatched types
528516
--> $DIR/numeric-cast.rs:142:16
@@ -709,12 +697,10 @@ error[E0308]: mismatched types
709697
--> $DIR/numeric-cast.rs:184:16
710698
|
711699
LL | foo::<i16>(x_u8);
712-
| ^^^^ expected `i16`, found `u8`
713-
|
714-
help: you can convert an `u8` to `i16` and panic if the converted value wouldn't fit
715-
|
716-
LL | foo::<i16>(x_u8.try_into().unwrap());
717-
| ^^^^^^^^^^^^^^^^^^^^^^^^
700+
| ^^^^
701+
| |
702+
| expected `i16`, found `u8`
703+
| help: you can convert an `u8` to `i16`: `x_u8.into()`
718704

719705
error[E0308]: mismatched types
720706
--> $DIR/numeric-cast.rs:186:16

src/test/ui/suggestions/integer-into.rs

-17
This file was deleted.

src/test/ui/suggestions/integer-into.stderr

-43
This file was deleted.

0 commit comments

Comments
 (0)