Skip to content

Commit 92d703f

Browse files
committed
Auto merge of #4021 - kraai:change-cast_lossless-warning, r=Manishearth
Change "if types change" to "if you later change the type" Fixes #3964. changelog: change wording of `cast_lossless` message
2 parents 9897442 + 9a43e09 commit 92d703f

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

clippy_lints/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ fn span_lossless_lint(cx: &LateContext<'_, '_>, expr: &Expr, op: &Expr, cast_fro
949949
CAST_LOSSLESS,
950950
expr.span,
951951
&format!(
952-
"casting {} to {} may become silently lossy if types change",
952+
"casting {} to {} may become silently lossy if you later change the type",
953953
cast_from, cast_to
954954
),
955955
"try",

tests/ui/cast_lossless_float.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
error: casting i8 to f32 may become silently lossy if types change
1+
error: casting i8 to f32 may become silently lossy if you later change the type
22
--> $DIR/cast_lossless_float.rs:9:5
33
|
44
LL | x0 as f32;
55
| ^^^^^^^^^ help: try: `f32::from(x0)`
66
|
77
= note: `-D clippy::cast-lossless` implied by `-D warnings`
88

9-
error: casting i8 to f64 may become silently lossy if types change
9+
error: casting i8 to f64 may become silently lossy if you later change the type
1010
--> $DIR/cast_lossless_float.rs:10:5
1111
|
1212
LL | x0 as f64;
1313
| ^^^^^^^^^ help: try: `f64::from(x0)`
1414

15-
error: casting u8 to f32 may become silently lossy if types change
15+
error: casting u8 to f32 may become silently lossy if you later change the type
1616
--> $DIR/cast_lossless_float.rs:12:5
1717
|
1818
LL | x1 as f32;
1919
| ^^^^^^^^^ help: try: `f32::from(x1)`
2020

21-
error: casting u8 to f64 may become silently lossy if types change
21+
error: casting u8 to f64 may become silently lossy if you later change the type
2222
--> $DIR/cast_lossless_float.rs:13:5
2323
|
2424
LL | x1 as f64;
2525
| ^^^^^^^^^ help: try: `f64::from(x1)`
2626

27-
error: casting i16 to f32 may become silently lossy if types change
27+
error: casting i16 to f32 may become silently lossy if you later change the type
2828
--> $DIR/cast_lossless_float.rs:15:5
2929
|
3030
LL | x2 as f32;
3131
| ^^^^^^^^^ help: try: `f32::from(x2)`
3232

33-
error: casting i16 to f64 may become silently lossy if types change
33+
error: casting i16 to f64 may become silently lossy if you later change the type
3434
--> $DIR/cast_lossless_float.rs:16:5
3535
|
3636
LL | x2 as f64;
3737
| ^^^^^^^^^ help: try: `f64::from(x2)`
3838

39-
error: casting u16 to f32 may become silently lossy if types change
39+
error: casting u16 to f32 may become silently lossy if you later change the type
4040
--> $DIR/cast_lossless_float.rs:18:5
4141
|
4242
LL | x3 as f32;
4343
| ^^^^^^^^^ help: try: `f32::from(x3)`
4444

45-
error: casting u16 to f64 may become silently lossy if types change
45+
error: casting u16 to f64 may become silently lossy if you later change the type
4646
--> $DIR/cast_lossless_float.rs:19:5
4747
|
4848
LL | x3 as f64;
4949
| ^^^^^^^^^ help: try: `f64::from(x3)`
5050

51-
error: casting i32 to f64 may become silently lossy if types change
51+
error: casting i32 to f64 may become silently lossy if you later change the type
5252
--> $DIR/cast_lossless_float.rs:21:5
5353
|
5454
LL | x4 as f64;
5555
| ^^^^^^^^^ help: try: `f64::from(x4)`
5656

57-
error: casting u32 to f64 may become silently lossy if types change
57+
error: casting u32 to f64 may become silently lossy if you later change the type
5858
--> $DIR/cast_lossless_float.rs:23:5
5959
|
6060
LL | x5 as f64;
6161
| ^^^^^^^^^ help: try: `f64::from(x5)`
6262

63-
error: casting f32 to f64 may become silently lossy if types change
63+
error: casting f32 to f64 may become silently lossy if you later change the type
6464
--> $DIR/cast_lossless_float.rs:26:5
6565
|
6666
LL | 1.0f32 as f64;

tests/ui/cast_lossless_integer.stderr

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
1-
error: casting i8 to i16 may become silently lossy if types change
1+
error: casting i8 to i16 may become silently lossy if you later change the type
22
--> $DIR/cast_lossless_integer.rs:8:5
33
|
44
LL | 1i8 as i16;
55
| ^^^^^^^^^^ help: try: `i16::from(1i8)`
66
|
77
= note: `-D clippy::cast-lossless` implied by `-D warnings`
88

9-
error: casting i8 to i32 may become silently lossy if types change
9+
error: casting i8 to i32 may become silently lossy if you later change the type
1010
--> $DIR/cast_lossless_integer.rs:9:5
1111
|
1212
LL | 1i8 as i32;
1313
| ^^^^^^^^^^ help: try: `i32::from(1i8)`
1414

15-
error: casting i8 to i64 may become silently lossy if types change
15+
error: casting i8 to i64 may become silently lossy if you later change the type
1616
--> $DIR/cast_lossless_integer.rs:10:5
1717
|
1818
LL | 1i8 as i64;
1919
| ^^^^^^^^^^ help: try: `i64::from(1i8)`
2020

21-
error: casting u8 to i16 may become silently lossy if types change
21+
error: casting u8 to i16 may become silently lossy if you later change the type
2222
--> $DIR/cast_lossless_integer.rs:11:5
2323
|
2424
LL | 1u8 as i16;
2525
| ^^^^^^^^^^ help: try: `i16::from(1u8)`
2626

27-
error: casting u8 to i32 may become silently lossy if types change
27+
error: casting u8 to i32 may become silently lossy if you later change the type
2828
--> $DIR/cast_lossless_integer.rs:12:5
2929
|
3030
LL | 1u8 as i32;
3131
| ^^^^^^^^^^ help: try: `i32::from(1u8)`
3232

33-
error: casting u8 to i64 may become silently lossy if types change
33+
error: casting u8 to i64 may become silently lossy if you later change the type
3434
--> $DIR/cast_lossless_integer.rs:13:5
3535
|
3636
LL | 1u8 as i64;
3737
| ^^^^^^^^^^ help: try: `i64::from(1u8)`
3838

39-
error: casting u8 to u16 may become silently lossy if types change
39+
error: casting u8 to u16 may become silently lossy if you later change the type
4040
--> $DIR/cast_lossless_integer.rs:14:5
4141
|
4242
LL | 1u8 as u16;
4343
| ^^^^^^^^^^ help: try: `u16::from(1u8)`
4444

45-
error: casting u8 to u32 may become silently lossy if types change
45+
error: casting u8 to u32 may become silently lossy if you later change the type
4646
--> $DIR/cast_lossless_integer.rs:15:5
4747
|
4848
LL | 1u8 as u32;
4949
| ^^^^^^^^^^ help: try: `u32::from(1u8)`
5050

51-
error: casting u8 to u64 may become silently lossy if types change
51+
error: casting u8 to u64 may become silently lossy if you later change the type
5252
--> $DIR/cast_lossless_integer.rs:16:5
5353
|
5454
LL | 1u8 as u64;
5555
| ^^^^^^^^^^ help: try: `u64::from(1u8)`
5656

57-
error: casting i16 to i32 may become silently lossy if types change
57+
error: casting i16 to i32 may become silently lossy if you later change the type
5858
--> $DIR/cast_lossless_integer.rs:17:5
5959
|
6060
LL | 1i16 as i32;
6161
| ^^^^^^^^^^^ help: try: `i32::from(1i16)`
6262

63-
error: casting i16 to i64 may become silently lossy if types change
63+
error: casting i16 to i64 may become silently lossy if you later change the type
6464
--> $DIR/cast_lossless_integer.rs:18:5
6565
|
6666
LL | 1i16 as i64;
6767
| ^^^^^^^^^^^ help: try: `i64::from(1i16)`
6868

69-
error: casting u16 to i32 may become silently lossy if types change
69+
error: casting u16 to i32 may become silently lossy if you later change the type
7070
--> $DIR/cast_lossless_integer.rs:19:5
7171
|
7272
LL | 1u16 as i32;
7373
| ^^^^^^^^^^^ help: try: `i32::from(1u16)`
7474

75-
error: casting u16 to i64 may become silently lossy if types change
75+
error: casting u16 to i64 may become silently lossy if you later change the type
7676
--> $DIR/cast_lossless_integer.rs:20:5
7777
|
7878
LL | 1u16 as i64;
7979
| ^^^^^^^^^^^ help: try: `i64::from(1u16)`
8080

81-
error: casting u16 to u32 may become silently lossy if types change
81+
error: casting u16 to u32 may become silently lossy if you later change the type
8282
--> $DIR/cast_lossless_integer.rs:21:5
8383
|
8484
LL | 1u16 as u32;
8585
| ^^^^^^^^^^^ help: try: `u32::from(1u16)`
8686

87-
error: casting u16 to u64 may become silently lossy if types change
87+
error: casting u16 to u64 may become silently lossy if you later change the type
8888
--> $DIR/cast_lossless_integer.rs:22:5
8989
|
9090
LL | 1u16 as u64;
9191
| ^^^^^^^^^^^ help: try: `u64::from(1u16)`
9292

93-
error: casting i32 to i64 may become silently lossy if types change
93+
error: casting i32 to i64 may become silently lossy if you later change the type
9494
--> $DIR/cast_lossless_integer.rs:23:5
9595
|
9696
LL | 1i32 as i64;
9797
| ^^^^^^^^^^^ help: try: `i64::from(1i32)`
9898

99-
error: casting u32 to i64 may become silently lossy if types change
99+
error: casting u32 to i64 may become silently lossy if you later change the type
100100
--> $DIR/cast_lossless_integer.rs:24:5
101101
|
102102
LL | 1u32 as i64;
103103
| ^^^^^^^^^^^ help: try: `i64::from(1u32)`
104104

105-
error: casting u32 to u64 may become silently lossy if types change
105+
error: casting u32 to u64 may become silently lossy if you later change the type
106106
--> $DIR/cast_lossless_integer.rs:25:5
107107
|
108108
LL | 1u32 as u64;
109109
| ^^^^^^^^^^^ help: try: `u64::from(1u32)`
110110

111-
error: casting u8 to u16 may become silently lossy if types change
111+
error: casting u8 to u16 may become silently lossy if you later change the type
112112
--> $DIR/cast_lossless_integer.rs:28:5
113113
|
114114
LL | (1u8 + 1u8) as u16;

tests/ui/types.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: casting i32 to i64 may become silently lossy if types change
1+
error: casting i32 to i64 may become silently lossy if you later change the type
22
--> $DIR/types.rs:13:22
33
|
44
LL | let c_i64: i64 = c as i64;

0 commit comments

Comments
 (0)