Skip to content

Commit e03a32f

Browse files
committed
Auto merge of rust-lang#5019 - JohnTitor:follow-up-normalize, r=phansch
Normalize lint messages in cast_precision_loss Follow-up of rust-lang#5000 changelog: none
2 parents baa5cc1 + 787106c commit e03a32f

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

clippy_lints/src/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@ fn span_precision_loss_lint(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cast_from
953953
CAST_PRECISION_LOSS,
954954
expr.span,
955955
&format!(
956-
"casting {0} to {1} causes a loss of precision {2}({0} is {3} bits wide, but {1}'s mantissa \
957-
is only {4} bits wide)",
956+
"casting `{0}` to `{1}` causes a loss of precision {2}(`{0}` is {3} bits wide, \
957+
but `{1}`'s mantissa is only {4} bits wide)",
958958
cast_from,
959959
if cast_to_f64 { "f64" } else { "f32" },
960960
if arch_dependent { arch_dependent_str } else { "" },

tests/ui/cast.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
1+
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
22
--> $DIR/cast.rs:11:5
33
|
44
LL | x0 as f32;
55
| ^^^^^^^^^
66
|
77
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
88

9-
error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
9+
error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
1010
--> $DIR/cast.rs:13:5
1111
|
1212
LL | x1 as f32;
1313
| ^^^^^^^^^
1414

15-
error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
15+
error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
1616
--> $DIR/cast.rs:14:5
1717
|
1818
LL | x1 as f64;
1919
| ^^^^^^^^^
2020

21-
error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
21+
error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
2222
--> $DIR/cast.rs:16:5
2323
|
2424
LL | x2 as f32;
2525
| ^^^^^^^^^
2626

27-
error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
27+
error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
2828
--> $DIR/cast.rs:18:5
2929
|
3030
LL | x3 as f32;
3131
| ^^^^^^^^^
3232

33-
error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
33+
error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
3434
--> $DIR/cast.rs:19:5
3535
|
3636
LL | x3 as f64;

tests/ui/cast_size.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ LL | 1isize as i8;
66
|
77
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
88

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)
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)
1010
--> $DIR/cast_size.rs:15:5
1111
|
1212
LL | x0 as f64;
1313
| ^^^^^^^^^
1414
|
1515
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
1616

17-
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)
17+
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)
1818
--> $DIR/cast_size.rs:16:5
1919
|
2020
LL | x1 as f64;
2121
| ^^^^^^^^^
2222

23-
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)
23+
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)
2424
--> $DIR/cast_size.rs:17:5
2525
|
2626
LL | x0 as f32;
2727
| ^^^^^^^^^
2828

29-
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)
29+
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)
3030
--> $DIR/cast_size.rs:18:5
3131
|
3232
LL | x1 as f32;
@@ -100,13 +100,13 @@ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit
100100
LL | 1u32 as isize;
101101
| ^^^^^^^^^^^^^
102102

103-
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
103+
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
104104
--> $DIR/cast_size.rs:33:5
105105
|
106106
LL | 999_999_999 as f32;
107107
| ^^^^^^^^^^^^^^^^^^
108108

109-
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)
109+
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)
110110
--> $DIR/cast_size.rs:34:5
111111
|
112112
LL | 9_999_999_999_999_999usize as f64;

tests/ui/cast_size_32bit.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | 1isize as i8;
66
|
77
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
88

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)
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)
1010
--> $DIR/cast_size_32bit.rs:15:5
1111
|
1212
LL | x0 as f64;
@@ -22,7 +22,7 @@ LL | x0 as f64;
2222
|
2323
= note: `-D clippy::cast-lossless` implied by `-D warnings`
2424

25-
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)
25+
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)
2626
--> $DIR/cast_size_32bit.rs:16:5
2727
|
2828
LL | x1 as f64;
@@ -34,13 +34,13 @@ error: casting `usize` to `f64` may become silently lossy if you later change th
3434
LL | x1 as f64;
3535
| ^^^^^^^^^ help: try: `f64::from(x1)`
3636

37-
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)
37+
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)
3838
--> $DIR/cast_size_32bit.rs:17:5
3939
|
4040
LL | x0 as f32;
4141
| ^^^^^^^^^
4242

43-
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)
43+
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)
4444
--> $DIR/cast_size_32bit.rs:18:5
4545
|
4646
LL | x1 as f32;
@@ -114,7 +114,7 @@ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit
114114
LL | 1u32 as isize;
115115
| ^^^^^^^^^^^^^
116116

117-
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
117+
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
118118
--> $DIR/cast_size_32bit.rs:33:5
119119
|
120120
LL | 999_999_999 as f32;

0 commit comments

Comments
 (0)