File: type-overflow.stderr

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (143 lines) | stat: -rw-r--r-- 6,429 bytes parent folder | download | duplicates (10)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
warning: literal out of range for `i8`
  --> $DIR/type-overflow.rs:5:17
   |
LL |     let error = 255i8;
   |                 ^^^^^
   |
   = note: the literal `255i8` does not fit into the type `i8` whose range is `-128..=127`
   = help: consider using the type `u8` instead
note: the lint level is defined here
  --> $DIR/type-overflow.rs:2:9
   |
LL | #![warn(overflowing_literals)]
   |         ^^^^^^^^^^^^^^^^^^^^

warning: literal out of range for `i8`
  --> $DIR/type-overflow.rs:11:16
   |
LL |     let fail = 0b1000_0001i8;
   |                ^^^^^^^^^^^^^
   |
   = note: the literal `0b1000_0001i8` (decimal `129`) does not fit into the type `i8` and will become `-127i8`
help: consider using the type `u8` instead
   |
LL -     let fail = 0b1000_0001i8;
LL +     let fail = 0b1000_0001u8;
   |
help: to use as a negative number (decimal `-127`), consider using the type `u8` for the literal and cast it to `i8`
   |
LL |     let fail = 0b1000_0001u8 as i8;
   |                           +++++

warning: literal out of range for `i64`
  --> $DIR/type-overflow.rs:15:16
   |
LL |     let fail = 0x8000_0000_0000_0000i64;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into the type `i64` and will become `-9223372036854775808i64`
help: consider using the type `u64` instead
   |
LL -     let fail = 0x8000_0000_0000_0000i64;
LL +     let fail = 0x8000_0000_0000_0000u64;
   |
help: to use as a negative number (decimal `-9223372036854775808`), consider using the type `u64` for the literal and cast it to `i64`
   |
LL |     let fail = 0x8000_0000_0000_0000u64 as i64;
   |                                     ++++++

warning: literal out of range for `u32`
  --> $DIR/type-overflow.rs:19:16
   |
LL |     let fail = 0x1_FFFF_FFFFu32;
   |                ^^^^^^^^^^^^^^^^ help: consider using the type `u64` instead: `0x1_FFFF_FFFFu64`
   |
   = note: the literal `0x1_FFFF_FFFFu32` (decimal `8589934591`) does not fit into the type `u32` and will become `4294967295u32`

warning: literal out of range for `i128`
  --> $DIR/type-overflow.rs:22:22
   |
LL |     let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000;
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i128` and will become `-170141183460469231731687303715884105728i128`
   = help: consider using the type `u128` instead
help: to use as a negative number (decimal `-170141183460469231731687303715884105728`), consider using the type `u128` for the literal and cast it to `i128`
   |
LL |     let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000u128 as i128;
   |                                                               ++++++++++++

warning: literal out of range for `i32`
  --> $DIR/type-overflow.rs:27:16
   |
LL |     let fail = 0x8000_0000_0000_0000_0000_0000_0000_0000;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i32` and will become `0i32`
   = help: consider using the type `u128` instead

warning: literal out of range for `i32`
  --> $DIR/type-overflow.rs:31:17
   |
LL |     let fail = -0x8000_0000_0000_0000_0000_0000_0000_0000; // issue #131849
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i32`
   = note: and the value `-0x8000_0000_0000_0000_0000_0000_0000_0000` will become `0i32`
   = help: consider using the type `i128` instead

warning: literal out of range for `i128`
  --> $DIR/type-overflow.rs:35:17
   |
LL |     let fail = -0x8000_0000_0000_0000_0000_0000_0000_0001i128;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0001i128` (decimal `170141183460469231731687303715884105729`) does not fit into the type `i128`
   = note: and the value `-0x8000_0000_0000_0000_0000_0000_0000_0001i128` will become `170141183460469231731687303715884105727i128`

warning: literal out of range for `i8`
  --> $DIR/type-overflow.rs:38:16
   |
LL |     let fail = 340282366920938463463374607431768211455i8;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `340282366920938463463374607431768211455i8` does not fit into the type `i8` whose range is `-128..=127`
   = help: consider using the type `u128` instead

warning: literal out of range for `i32`
  --> $DIR/type-overflow.rs:42:16
   |
LL |     let fail = 0x8FFF_FFFF_FFFF_FFFE;
   |                ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
   = help: consider using the type `u64` instead
help: to use as a negative number (decimal `-2`), consider using the type `u64` for the literal and cast it to `i32`
   |
LL |     let fail = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
   |                                     ++++++++++

warning: literal out of range for `i8`
  --> $DIR/type-overflow.rs:46:17
   |
LL |     let fail = -0b1111_1111i8;
   |                 ^^^^^^^^^^^^^ help: consider using the type `i16` instead: `0b1111_1111i16`
   |
   = note: the literal `0b1111_1111i8` (decimal `255`) does not fit into the type `i8`
   = note: and the value `-0b1111_1111i8` will become `1i8`

warning: literal out of range for `i32`
  --> $DIR/type-overflow.rs:49:16
   |
LL |     let fail = 0x8000_0000_0000_0000_0000_0000_FFFF_FFFE;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the literal `0x8000_0000_0000_0000_0000_0000_FFFF_FFFE` (decimal `170141183460469231731687303720179073022`) does not fit into the type `i32` and will become `-2i32`
   = help: consider using the type `u128` instead
help: to use as a negative number (decimal `-2`), consider using the type `u128` for the literal and cast it to `i32`
   |
LL |     let fail = 0x8000_0000_0000_0000_0000_0000_FFFF_FFFEu128 as i32;
   |                                                         +++++++++++

warning: 12 warnings emitted