Skip to content

Commit 2c0c661

Browse files
Better handle 32bit/64bit-specific ui tests
1 parent 8ae4e7f commit 2c0c661

9 files changed

+155
-143
lines changed

tests/ui/cast_size.32bit.stderr

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: casting `isize` to `i8` may truncate the value
2-
--> tests/ui/cast_size.rs:15:5
2+
--> tests/ui/cast_size.rs:17:5
33
|
44
LL | 1isize as i8;
55
| ^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL | i8::try_from(1isize);
1313
| ~~~~~~~~~~~~~~~~~~~~
1414

1515
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
16-
--> tests/ui/cast_size.rs:22:5
16+
--> tests/ui/cast_size.rs:24:5
1717
|
1818
LL | x0 as f32;
1919
| ^^^^^^^^^
@@ -22,25 +22,25 @@ LL | x0 as f32;
2222
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
2323

2424
error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
25-
--> tests/ui/cast_size.rs:24:5
25+
--> tests/ui/cast_size.rs:26:5
2626
|
2727
LL | x1 as f32;
2828
| ^^^^^^^^^
2929

3030
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
31-
--> tests/ui/cast_size.rs:26:5
31+
--> tests/ui/cast_size.rs:28:5
3232
|
3333
LL | x0 as f64;
3434
| ^^^^^^^^^
3535

3636
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
37-
--> tests/ui/cast_size.rs:28:5
37+
--> tests/ui/cast_size.rs:30:5
3838
|
3939
LL | x1 as f64;
4040
| ^^^^^^^^^
4141

4242
error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
43-
--> tests/ui/cast_size.rs:33:5
43+
--> tests/ui/cast_size.rs:35:5
4444
|
4545
LL | 1isize as i32;
4646
| ^^^^^^^^^^^^^
@@ -52,7 +52,7 @@ LL | i32::try_from(1isize);
5252
| ~~~~~~~~~~~~~~~~~~~~~
5353

5454
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
55-
--> tests/ui/cast_size.rs:35:5
55+
--> tests/ui/cast_size.rs:37:5
5656
|
5757
LL | 1isize as u32;
5858
| ^^^^^^^^^^^^^
@@ -64,7 +64,7 @@ LL | u32::try_from(1isize);
6464
| ~~~~~~~~~~~~~~~~~~~~~
6565

6666
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
67-
--> tests/ui/cast_size.rs:37:5
67+
--> tests/ui/cast_size.rs:39:5
6868
|
6969
LL | 1usize as u32;
7070
| ^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | u32::try_from(1usize);
7676
| ~~~~~~~~~~~~~~~~~~~~~
7777

7878
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
79-
--> tests/ui/cast_size.rs:39:5
79+
--> tests/ui/cast_size.rs:41:5
8080
|
8181
LL | 1usize as i32;
8282
| ^^^^^^^^^^^^^
@@ -88,7 +88,7 @@ LL | i32::try_from(1usize);
8888
| ~~~~~~~~~~~~~~~~~~~~~
8989

9090
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
91-
--> tests/ui/cast_size.rs:39:5
91+
--> tests/ui/cast_size.rs:41:5
9292
|
9393
LL | 1usize as i32;
9494
| ^^^^^^^^^^^^^
@@ -97,7 +97,7 @@ LL | 1usize as i32;
9797
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
9898

9999
error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
100-
--> tests/ui/cast_size.rs:42:5
100+
--> tests/ui/cast_size.rs:44:5
101101
|
102102
LL | 1i64 as isize;
103103
| ^^^^^^^^^^^^^
@@ -109,7 +109,7 @@ LL | isize::try_from(1i64);
109109
| ~~~~~~~~~~~~~~~~~~~~~
110110

111111
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
112-
--> tests/ui/cast_size.rs:44:5
112+
--> tests/ui/cast_size.rs:46:5
113113
|
114114
LL | 1i64 as usize;
115115
| ^^^^^^^^^^^^^
@@ -121,7 +121,7 @@ LL | usize::try_from(1i64);
121121
| ~~~~~~~~~~~~~~~~~~~~~
122122

123123
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
124-
--> tests/ui/cast_size.rs:46:5
124+
--> tests/ui/cast_size.rs:48:5
125125
|
126126
LL | 1u64 as isize;
127127
| ^^^^^^^^^^^^^
@@ -133,13 +133,13 @@ LL | isize::try_from(1u64);
133133
| ~~~~~~~~~~~~~~~~~~~~~
134134

135135
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
136-
--> tests/ui/cast_size.rs:46:5
136+
--> tests/ui/cast_size.rs:48:5
137137
|
138138
LL | 1u64 as isize;
139139
| ^^^^^^^^^^^^^
140140

141141
error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
142-
--> tests/ui/cast_size.rs:49:5
142+
--> tests/ui/cast_size.rs:51:5
143143
|
144144
LL | 1u64 as usize;
145145
| ^^^^^^^^^^^^^
@@ -151,25 +151,25 @@ LL | usize::try_from(1u64);
151151
| ~~~~~~~~~~~~~~~~~~~~~
152152

153153
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
154-
--> tests/ui/cast_size.rs:51:5
154+
--> tests/ui/cast_size.rs:53:5
155155
|
156156
LL | 1u32 as isize;
157157
| ^^^^^^^^^^^^^
158158

159159
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
160-
--> tests/ui/cast_size.rs:59:5
160+
--> tests/ui/cast_size.rs:61:5
161161
|
162162
LL | 999_999_999 as f32;
163163
| ^^^^^^^^^^^^^^^^^^
164164

165165
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
166-
--> tests/ui/cast_size.rs:61:5
166+
--> tests/ui/cast_size.rs:63:5
167167
|
168168
LL | 9_999_999_999_999_999usize as f64;
169169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170170

171171
error: literal out of range for `usize`
172-
--> tests/ui/cast_size.rs:61:5
172+
--> tests/ui/cast_size.rs:63:5
173173
|
174174
LL | 9_999_999_999_999_999usize as f64;
175175
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/cast_size.64bit.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: casting `isize` to `i8` may truncate the value
2-
--> tests/ui/cast_size.rs:15:5
2+
--> tests/ui/cast_size.rs:17:5
33
|
44
LL | 1isize as i8;
55
| ^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL | i8::try_from(1isize);
1313
| ~~~~~~~~~~~~~~~~~~~~
1414

1515
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
16-
--> tests/ui/cast_size.rs:22:5
16+
--> tests/ui/cast_size.rs:24:5
1717
|
1818
LL | x0 as f32;
1919
| ^^^^^^^^^
@@ -22,25 +22,25 @@ LL | x0 as f32;
2222
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`
2323

2424
error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
25-
--> tests/ui/cast_size.rs:24:5
25+
--> tests/ui/cast_size.rs:26:5
2626
|
2727
LL | x1 as f32;
2828
| ^^^^^^^^^
2929

3030
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
31-
--> tests/ui/cast_size.rs:26:5
31+
--> tests/ui/cast_size.rs:28:5
3232
|
3333
LL | x0 as f64;
3434
| ^^^^^^^^^
3535

3636
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
37-
--> tests/ui/cast_size.rs:28:5
37+
--> tests/ui/cast_size.rs:30:5
3838
|
3939
LL | x1 as f64;
4040
| ^^^^^^^^^
4141

4242
error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
43-
--> tests/ui/cast_size.rs:33:5
43+
--> tests/ui/cast_size.rs:35:5
4444
|
4545
LL | 1isize as i32;
4646
| ^^^^^^^^^^^^^
@@ -52,7 +52,7 @@ LL | i32::try_from(1isize);
5252
| ~~~~~~~~~~~~~~~~~~~~~
5353

5454
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
55-
--> tests/ui/cast_size.rs:35:5
55+
--> tests/ui/cast_size.rs:37:5
5656
|
5757
LL | 1isize as u32;
5858
| ^^^^^^^^^^^^^
@@ -64,7 +64,7 @@ LL | u32::try_from(1isize);
6464
| ~~~~~~~~~~~~~~~~~~~~~
6565

6666
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
67-
--> tests/ui/cast_size.rs:37:5
67+
--> tests/ui/cast_size.rs:39:5
6868
|
6969
LL | 1usize as u32;
7070
| ^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | u32::try_from(1usize);
7676
| ~~~~~~~~~~~~~~~~~~~~~
7777

7878
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
79-
--> tests/ui/cast_size.rs:39:5
79+
--> tests/ui/cast_size.rs:41:5
8080
|
8181
LL | 1usize as i32;
8282
| ^^^^^^^^^^^^^
@@ -88,7 +88,7 @@ LL | i32::try_from(1usize);
8888
| ~~~~~~~~~~~~~~~~~~~~~
8989

9090
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
91-
--> tests/ui/cast_size.rs:39:5
91+
--> tests/ui/cast_size.rs:41:5
9292
|
9393
LL | 1usize as i32;
9494
| ^^^^^^^^^^^^^
@@ -97,7 +97,7 @@ LL | 1usize as i32;
9797
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`
9898

9999
error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
100-
--> tests/ui/cast_size.rs:42:5
100+
--> tests/ui/cast_size.rs:44:5
101101
|
102102
LL | 1i64 as isize;
103103
| ^^^^^^^^^^^^^
@@ -109,7 +109,7 @@ LL | isize::try_from(1i64);
109109
| ~~~~~~~~~~~~~~~~~~~~~
110110

111111
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
112-
--> tests/ui/cast_size.rs:44:5
112+
--> tests/ui/cast_size.rs:46:5
113113
|
114114
LL | 1i64 as usize;
115115
| ^^^^^^^^^^^^^
@@ -121,7 +121,7 @@ LL | usize::try_from(1i64);
121121
| ~~~~~~~~~~~~~~~~~~~~~
122122

123123
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
124-
--> tests/ui/cast_size.rs:46:5
124+
--> tests/ui/cast_size.rs:48:5
125125
|
126126
LL | 1u64 as isize;
127127
| ^^^^^^^^^^^^^
@@ -133,13 +133,13 @@ LL | isize::try_from(1u64);
133133
| ~~~~~~~~~~~~~~~~~~~~~
134134

135135
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
136-
--> tests/ui/cast_size.rs:46:5
136+
--> tests/ui/cast_size.rs:48:5
137137
|
138138
LL | 1u64 as isize;
139139
| ^^^^^^^^^^^^^
140140

141141
error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
142-
--> tests/ui/cast_size.rs:49:5
142+
--> tests/ui/cast_size.rs:51:5
143143
|
144144
LL | 1u64 as usize;
145145
| ^^^^^^^^^^^^^
@@ -151,19 +151,19 @@ LL | usize::try_from(1u64);
151151
| ~~~~~~~~~~~~~~~~~~~~~
152152

153153
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
154-
--> tests/ui/cast_size.rs:51:5
154+
--> tests/ui/cast_size.rs:53:5
155155
|
156156
LL | 1u32 as isize;
157157
| ^^^^^^^^^^^^^
158158

159159
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
160-
--> tests/ui/cast_size.rs:59:5
160+
--> tests/ui/cast_size.rs:61:5
161161
|
162162
LL | 999_999_999 as f32;
163163
| ^^^^^^^^^^^^^^^^^^
164164

165165
error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
166-
--> tests/ui/cast_size.rs:61:5
166+
--> tests/ui/cast_size.rs:63:5
167167
|
168168
LL | 9_999_999_999_999_999usize as f64;
169169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/cast_size.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//@stderr-per-bitwidth
1+
//@revisions: 32bit 64bit
2+
//@[32bit]ignore-bitwidth: 64
3+
//@[64bit]ignore-bitwidth: 32
24
//@no-rustfix
35

46
#![warn(
@@ -60,5 +62,6 @@ fn main() {
6062
//~^ cast_precision_loss
6163
9_999_999_999_999_999usize as f64;
6264
//~^ cast_precision_loss
65+
//~[32bit]^^ overflowing_literals
6366
// 999_999_999_999_999_999_999_999_999_999u128 as f128;
6467
}

0 commit comments

Comments
 (0)