Skip to content

Commit 8407957

Browse files
committed
Fix fn_to_numeric_cast UI tests
This collapses both lint tests into one file. Somehow allowing the other lint in the respective files did not work correctly. Maybe that's fixed as part of fixing #3198.
1 parent 1544a1a commit 8407957

4 files changed

+66
-128
lines changed

tests/ui/fn_to_numeric_cast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// only-64bit
12
#![feature(tool_lints)]
23

3-
#![warn(clippy::fn_to_numeric_cast)]
4+
#![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
45

56
fn foo() -> String { String::new() }
67

tests/ui/fn_to_numeric_cast.stderr

+64-62
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,143 @@
1-
error: casting function pointer `foo` to `i8`
2-
--> $DIR/fn_to_numeric_cast.rs:8:13
1+
error: casting function pointer `foo` to `i8`, which truncates the value
2+
--> $DIR/fn_to_numeric_cast.rs:9:13
33
|
4-
8 | let _ = foo as i8;
4+
9 | let _ = foo as i8;
55
| ^^^^^^^^^ help: try: `foo as usize`
66
|
7-
= note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
7+
= note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
88

9-
error: casting function pointer `foo` to `i16`
10-
--> $DIR/fn_to_numeric_cast.rs:9:13
11-
|
12-
9 | let _ = foo as i16;
13-
| ^^^^^^^^^^ help: try: `foo as usize`
14-
15-
error: casting function pointer `foo` to `i32`
9+
error: casting function pointer `foo` to `i16`, which truncates the value
1610
--> $DIR/fn_to_numeric_cast.rs:10:13
1711
|
18-
10 | let _ = foo as i32;
12+
10 | let _ = foo as i16;
1913
| ^^^^^^^^^^ help: try: `foo as usize`
2014

21-
error: casting function pointer `foo` to `i64`
15+
error: casting function pointer `foo` to `i32`, which truncates the value
2216
--> $DIR/fn_to_numeric_cast.rs:11:13
2317
|
24-
11 | let _ = foo as i64;
18+
11 | let _ = foo as i32;
2519
| ^^^^^^^^^^ help: try: `foo as usize`
2620

27-
error: casting function pointer `foo` to `i128`
21+
error: casting function pointer `foo` to `i64`
2822
--> $DIR/fn_to_numeric_cast.rs:12:13
2923
|
30-
12 | let _ = foo as i128;
24+
12 | let _ = foo as i64;
25+
| ^^^^^^^^^^ help: try: `foo as usize`
26+
|
27+
= note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
28+
29+
error: casting function pointer `foo` to `i128`
30+
--> $DIR/fn_to_numeric_cast.rs:13:13
31+
|
32+
13 | let _ = foo as i128;
3133
| ^^^^^^^^^^^ help: try: `foo as usize`
3234

3335
error: casting function pointer `foo` to `isize`
34-
--> $DIR/fn_to_numeric_cast.rs:13:13
36+
--> $DIR/fn_to_numeric_cast.rs:14:13
3537
|
36-
13 | let _ = foo as isize;
38+
14 | let _ = foo as isize;
3739
| ^^^^^^^^^^^^ help: try: `foo as usize`
3840

39-
error: casting function pointer `foo` to `u8`
40-
--> $DIR/fn_to_numeric_cast.rs:15:13
41+
error: casting function pointer `foo` to `u8`, which truncates the value
42+
--> $DIR/fn_to_numeric_cast.rs:16:13
4143
|
42-
15 | let _ = foo as u8;
44+
16 | let _ = foo as u8;
4345
| ^^^^^^^^^ help: try: `foo as usize`
4446

45-
error: casting function pointer `foo` to `u16`
46-
--> $DIR/fn_to_numeric_cast.rs:16:13
47+
error: casting function pointer `foo` to `u16`, which truncates the value
48+
--> $DIR/fn_to_numeric_cast.rs:17:13
4749
|
48-
16 | let _ = foo as u16;
50+
17 | let _ = foo as u16;
4951
| ^^^^^^^^^^ help: try: `foo as usize`
5052

51-
error: casting function pointer `foo` to `u32`
52-
--> $DIR/fn_to_numeric_cast.rs:17:13
53+
error: casting function pointer `foo` to `u32`, which truncates the value
54+
--> $DIR/fn_to_numeric_cast.rs:18:13
5355
|
54-
17 | let _ = foo as u32;
56+
18 | let _ = foo as u32;
5557
| ^^^^^^^^^^ help: try: `foo as usize`
5658

5759
error: casting function pointer `foo` to `u64`
58-
--> $DIR/fn_to_numeric_cast.rs:18:13
60+
--> $DIR/fn_to_numeric_cast.rs:19:13
5961
|
60-
18 | let _ = foo as u64;
62+
19 | let _ = foo as u64;
6163
| ^^^^^^^^^^ help: try: `foo as usize`
6264

6365
error: casting function pointer `foo` to `u128`
64-
--> $DIR/fn_to_numeric_cast.rs:19:13
66+
--> $DIR/fn_to_numeric_cast.rs:20:13
6567
|
66-
19 | let _ = foo as u128;
68+
20 | let _ = foo as u128;
6769
| ^^^^^^^^^^^ help: try: `foo as usize`
6870

69-
error: casting function pointer `abc` to `i8`
70-
--> $DIR/fn_to_numeric_cast.rs:28:13
71+
error: casting function pointer `abc` to `i8`, which truncates the value
72+
--> $DIR/fn_to_numeric_cast.rs:29:13
7173
|
72-
28 | let _ = abc as i8;
74+
29 | let _ = abc as i8;
7375
| ^^^^^^^^^ help: try: `abc as usize`
7476

75-
error: casting function pointer `abc` to `i16`
76-
--> $DIR/fn_to_numeric_cast.rs:29:13
77+
error: casting function pointer `abc` to `i16`, which truncates the value
78+
--> $DIR/fn_to_numeric_cast.rs:30:13
7779
|
78-
29 | let _ = abc as i16;
80+
30 | let _ = abc as i16;
7981
| ^^^^^^^^^^ help: try: `abc as usize`
8082

81-
error: casting function pointer `abc` to `i32`
82-
--> $DIR/fn_to_numeric_cast.rs:30:13
83+
error: casting function pointer `abc` to `i32`, which truncates the value
84+
--> $DIR/fn_to_numeric_cast.rs:31:13
8385
|
84-
30 | let _ = abc as i32;
86+
31 | let _ = abc as i32;
8587
| ^^^^^^^^^^ help: try: `abc as usize`
8688

8789
error: casting function pointer `abc` to `i64`
88-
--> $DIR/fn_to_numeric_cast.rs:31:13
90+
--> $DIR/fn_to_numeric_cast.rs:32:13
8991
|
90-
31 | let _ = abc as i64;
92+
32 | let _ = abc as i64;
9193
| ^^^^^^^^^^ help: try: `abc as usize`
9294

9395
error: casting function pointer `abc` to `i128`
94-
--> $DIR/fn_to_numeric_cast.rs:32:13
96+
--> $DIR/fn_to_numeric_cast.rs:33:13
9597
|
96-
32 | let _ = abc as i128;
98+
33 | let _ = abc as i128;
9799
| ^^^^^^^^^^^ help: try: `abc as usize`
98100

99101
error: casting function pointer `abc` to `isize`
100-
--> $DIR/fn_to_numeric_cast.rs:33:13
102+
--> $DIR/fn_to_numeric_cast.rs:34:13
101103
|
102-
33 | let _ = abc as isize;
104+
34 | let _ = abc as isize;
103105
| ^^^^^^^^^^^^ help: try: `abc as usize`
104106

105-
error: casting function pointer `abc` to `u8`
106-
--> $DIR/fn_to_numeric_cast.rs:35:13
107+
error: casting function pointer `abc` to `u8`, which truncates the value
108+
--> $DIR/fn_to_numeric_cast.rs:36:13
107109
|
108-
35 | let _ = abc as u8;
110+
36 | let _ = abc as u8;
109111
| ^^^^^^^^^ help: try: `abc as usize`
110112

111-
error: casting function pointer `abc` to `u16`
112-
--> $DIR/fn_to_numeric_cast.rs:36:13
113+
error: casting function pointer `abc` to `u16`, which truncates the value
114+
--> $DIR/fn_to_numeric_cast.rs:37:13
113115
|
114-
36 | let _ = abc as u16;
116+
37 | let _ = abc as u16;
115117
| ^^^^^^^^^^ help: try: `abc as usize`
116118

117-
error: casting function pointer `abc` to `u32`
118-
--> $DIR/fn_to_numeric_cast.rs:37:13
119+
error: casting function pointer `abc` to `u32`, which truncates the value
120+
--> $DIR/fn_to_numeric_cast.rs:38:13
119121
|
120-
37 | let _ = abc as u32;
122+
38 | let _ = abc as u32;
121123
| ^^^^^^^^^^ help: try: `abc as usize`
122124

123125
error: casting function pointer `abc` to `u64`
124-
--> $DIR/fn_to_numeric_cast.rs:38:13
126+
--> $DIR/fn_to_numeric_cast.rs:39:13
125127
|
126-
38 | let _ = abc as u64;
128+
39 | let _ = abc as u64;
127129
| ^^^^^^^^^^ help: try: `abc as usize`
128130

129131
error: casting function pointer `abc` to `u128`
130-
--> $DIR/fn_to_numeric_cast.rs:39:13
132+
--> $DIR/fn_to_numeric_cast.rs:40:13
131133
|
132-
39 | let _ = abc as u128;
134+
40 | let _ = abc as u128;
133135
| ^^^^^^^^^^^ help: try: `abc as usize`
134136

135-
error: casting function pointer `f` to `i32`
136-
--> $DIR/fn_to_numeric_cast.rs:46:5
137+
error: casting function pointer `f` to `i32`, which truncates the value
138+
--> $DIR/fn_to_numeric_cast.rs:47:5
137139
|
138-
46 | f as i32
140+
47 | f as i32
139141
| ^^^^^^^^ help: try: `f as usize`
140142

141143
error: aborting due to 23 previous errors

tests/ui/fn_to_numeric_cast_with_truncation.rs

-25
This file was deleted.

tests/ui/fn_to_numeric_cast_with_truncation.stderr

-40
This file was deleted.

0 commit comments

Comments
 (0)