You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/ui/cast_size.stderr
+9-62Lines changed: 9 additions & 62 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,9 @@ error: casting `isize` to `i8` may truncate the value
2
2
--> $DIR/cast_size.rs:12:5
3
3
|
4
4
LL | 1isize as i8;
5
-
| ^^^^^^^^^^^^
5
+
| ^^^^^^^^^^^^ help: avoid silent truncation by using: `i8::try_from(1isize).unwrap()`
6
6
|
7
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
8
7
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
9
-
help: ... or use `try_from` and handle the error accordingly
10
-
|
11
-
LL | i8::try_from(1isize);
12
-
| ~~~~~~~~~~~~~~~~~~~~
13
8
14
9
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)
15
10
--> $DIR/cast_size.rs:15:5
@@ -41,49 +36,25 @@ error: casting `isize` to `i32` may truncate the value on targets with 64-bit wi
41
36
--> $DIR/cast_size.rs:19:5
42
37
|
43
38
LL | 1isize as i32;
44
-
| ^^^^^^^^^^^^^
45
-
|
46
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
47
-
help: ... or use `try_from` and handle the error accordingly
48
-
|
49
-
LL | i32::try_from(1isize);
50
-
| ~~~~~~~~~~~~~~~~~~~~~
39
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `i32::try_from(1isize).unwrap()`
51
40
52
41
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
53
42
--> $DIR/cast_size.rs:20:5
54
43
|
55
44
LL | 1isize as u32;
56
-
| ^^^^^^^^^^^^^
57
-
|
58
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
59
-
help: ... or use `try_from` and handle the error accordingly
60
-
|
61
-
LL | u32::try_from(1isize);
62
-
| ~~~~~~~~~~~~~~~~~~~~~
45
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `u32::try_from(1isize).unwrap()`
63
46
64
47
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
65
48
--> $DIR/cast_size.rs:21:5
66
49
|
67
50
LL | 1usize as u32;
68
-
| ^^^^^^^^^^^^^
69
-
|
70
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
71
-
help: ... or use `try_from` and handle the error accordingly
72
-
|
73
-
LL | u32::try_from(1usize);
74
-
| ~~~~~~~~~~~~~~~~~~~~~
51
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `u32::try_from(1usize).unwrap()`
75
52
76
53
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
77
54
--> $DIR/cast_size.rs:22:5
78
55
|
79
56
LL | 1usize as i32;
80
-
| ^^^^^^^^^^^^^
81
-
|
82
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
83
-
help: ... or use `try_from` and handle the error accordingly
84
-
|
85
-
LL | i32::try_from(1usize);
86
-
| ~~~~~~~~~~~~~~~~~~~~~
57
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `i32::try_from(1usize).unwrap()`
87
58
88
59
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
89
60
--> $DIR/cast_size.rs:22:5
@@ -97,37 +68,19 @@ error: casting `i64` to `isize` may truncate the value on targets with 32-bit wi
97
68
--> $DIR/cast_size.rs:24:5
98
69
|
99
70
LL | 1i64 as isize;
100
-
| ^^^^^^^^^^^^^
101
-
|
102
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
103
-
help: ... or use `try_from` and handle the error accordingly
104
-
|
105
-
LL | isize::try_from(1i64);
106
-
| ~~~~~~~~~~~~~~~~~~~~~
71
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `isize::try_from(1i64).unwrap()`
107
72
108
73
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
109
74
--> $DIR/cast_size.rs:25:5
110
75
|
111
76
LL | 1i64 as usize;
112
-
| ^^^^^^^^^^^^^
113
-
|
114
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
115
-
help: ... or use `try_from` and handle the error accordingly
116
-
|
117
-
LL | usize::try_from(1i64);
118
-
| ~~~~~~~~~~~~~~~~~~~~~
77
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `usize::try_from(1i64).unwrap()`
119
78
120
79
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
121
80
--> $DIR/cast_size.rs:26:5
122
81
|
123
82
LL | 1u64 as isize;
124
-
| ^^^^^^^^^^^^^
125
-
|
126
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
127
-
help: ... or use `try_from` and handle the error accordingly
128
-
|
129
-
LL | isize::try_from(1u64);
130
-
| ~~~~~~~~~~~~~~~~~~~~~
83
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `isize::try_from(1u64).unwrap()`
131
84
132
85
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
133
86
--> $DIR/cast_size.rs:26:5
@@ -139,13 +92,7 @@ error: casting `u64` to `usize` may truncate the value on targets with 32-bit wi
139
92
--> $DIR/cast_size.rs:27:5
140
93
|
141
94
LL | 1u64 as usize;
142
-
| ^^^^^^^^^^^^^
143
-
|
144
-
= help: if this is intentional allow the lint with `#[allow(clippy::cast_precision_loss)]` ...
145
-
help: ... or use `try_from` and handle the error accordingly
146
-
|
147
-
LL | usize::try_from(1u64);
148
-
| ~~~~~~~~~~~~~~~~~~~~~
95
+
| ^^^^^^^^^^^^^ help: avoid silent truncation by using: `usize::try_from(1u64).unwrap()`
149
96
150
97
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
0 commit comments