-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit 142ad69
Rollup merge of #146042 - estebank:issue-83413, r=lcnr
Detect negative literal inferred to unsigned integer
```
error[E0277]: the trait bound `usize: Neg` is not satisfied
--> $DIR/negative-literal-infered-to-unsigned.rs:2:14
|
LL | for x in -5..5 {
| ^^ the trait `Neg` is not implemented for `usize`
|
help: consider specifying an integer type that can be negative
|
LL | for x in -5isize..5 {
| +++++
```
Applying this suggestion will always end up in another E0308 error at the point where the unsigned inference comes from, which should help with understanding what the actual problem is.
Fix #83413.File tree
6 files changed
+103
-27
lines changed- compiler
- rustc_hir_typeck/src
- rustc_middle/src/traits
- rustc_trait_selection/src/error_reporting/traits
- tests/ui/suggestions
6 files changed
+103
-27
lines changedLines changed: 9 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
962 | 962 |
| |
963 | 963 |
| |
964 | 964 |
| |
965 | - | ||
966 | - | ||
967 | - | ||
968 | - | ||
969 | - | ||
970 | - | ||
971 | - | ||
965 | + | ||
966 | + | ||
967 | + | ||
968 | + | ||
969 | + | ||
970 | + | ||
971 | + | ||
972 | + | ||
973 | + | ||
972 | 974 |
| |
973 | 975 |
| |
974 | 976 |
| |
|
Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
392 | + | ||
393 | + | ||
394 | + | ||
395 | + | ||
392 | 396 |
| |
393 | 397 |
| |
394 | - | ||
395 | - | ||
398 | + | ||
399 | + | ||
396 | 400 |
| |
397 | 401 |
| |
398 | 402 |
| |
|
Lines changed: 41 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 | - | ||
6 | + | ||
7 | + | ||
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
| |||
280 | 281 |
| |
281 | 282 |
| |
282 | 283 |
| |
284 | + | ||
285 | + | ||
286 | + | ||
287 | + | ||
288 | + | ||
289 | + | ||
283 | 290 |
| |
284 | 291 |
| |
285 | 292 |
| |
| |||
950 | 957 |
| |
951 | 958 |
| |
952 | 959 |
| |
960 | + | ||
961 | + | ||
962 | + | ||
963 | + | ||
964 | + | ||
965 | + | ||
966 | + | ||
967 | + | ||
968 | + | ||
969 | + | ||
970 | + | ||
971 | + | ||
972 | + | ||
973 | + | ||
974 | + | ||
975 | + | ||
976 | + | ||
977 | + | ||
978 | + | ||
979 | + | ||
980 | + | ||
981 | + | ||
982 | + | ||
983 | + | ||
984 | + | ||
985 | + | ||
986 | + | ||
987 | + | ||
988 | + | ||
989 | + | ||
990 | + | ||
991 | + | ||
953 | 992 |
| |
954 | 993 |
| |
955 | 994 |
| |
| |||
2730 | 2769 |
| |
2731 | 2770 |
| |
2732 | 2771 |
| |
2733 | - | ||
2734 | - | ||
2735 | - | ||
2772 | + | ||
2736 | 2773 |
| |
2737 | 2774 |
| |
2738 | 2775 |
| |
|
Lines changed: 9 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
554 | 554 |
| |
555 | 555 |
| |
556 | 556 |
| |
557 | - | ||
557 | + | ||
558 | 558 |
| |
559 | 559 |
| |
560 | 560 |
| |
| |||
2801 | 2801 |
| |
2802 | 2802 |
| |
2803 | 2803 |
| |
2804 | + | ||
2804 | 2805 |
| |
2805 | 2806 |
| |
2806 | 2807 |
| |
| |||
3839 | 3840 |
| |
3840 | 3841 |
| |
3841 | 3842 |
| |
3842 | - | ||
3843 | - | ||
3844 | - | ||
3843 | + | ||
3845 | 3844 |
| |
3846 | 3845 |
| |
3847 | 3846 |
| |
| |||
5108 | 5107 |
| |
5109 | 5108 |
| |
5110 | 5109 |
| |
5111 | - | ||
5112 | - | ||
5113 | - | ||
5114 | - | ||
5115 | - | ||
5116 | - | ||
5117 | - | ||
5118 | - | ||
5119 | - | ||
5120 | - | ||
5110 | + | ||
5111 | + | ||
5112 | + | ||
5113 | + | ||
5114 | + | ||
5115 | + | ||
5121 | 5116 |
| |
5122 | 5117 |
| |
5123 | 5118 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + |
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + | ||
24 | + | ||
25 | + |
0 commit comments