Skip to content

Commit 24d757e

Browse files
Allow function_casts_as_integer in non-related clippy ui tests
1 parent f68fe8e commit 24d757e

19 files changed

+87
-82
lines changed

src/tools/clippy/clippy_lints/src/disallowed_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use clippy_config::Conf;
32
use clippy_config::types::{DisallowedPath, create_disallowed_map};
43
use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then};

src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use clippy_utils::{
1111
use rustc_errors::Applicability;
1212
use rustc_lint::LateContext;
1313
use rustc_middle::ty;
14-
use rustc_span::Span;
15-
use rustc_span::Symbol;
14+
use rustc_span::{Span, Symbol};
1615
use {rustc_ast as ast, rustc_hir as hir};
1716

1817
use super::{OR_FUN_CALL, UNWRAP_OR_DEFAULT};

src/tools/clippy/tests/ui/cast_enum_constructor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::cast_enum_constructor)]
2-
#![allow(clippy::fn_to_numeric_cast)]
2+
#![allow(clippy::fn_to_numeric_cast, function_casts_as_integer)]
33

44
fn main() {
55
enum Foo {

src/tools/clippy/tests/ui/confusing_method_to_numeric_cast.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(float_minimum_maximum)]
22
#![warn(clippy::confusing_method_to_numeric_cast)]
3+
#![allow(function_casts_as_integer)]
34

45
fn main() {
56
let _ = u16::MAX as usize; //~ confusing_method_to_numeric_cast

src/tools/clippy/tests/ui/confusing_method_to_numeric_cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(float_minimum_maximum)]
22
#![warn(clippy::confusing_method_to_numeric_cast)]
3+
#![allow(function_casts_as_integer)]
34

45
fn main() {
56
let _ = u16::max as usize; //~ confusing_method_to_numeric_cast

src/tools/clippy/tests/ui/confusing_method_to_numeric_cast.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: casting function pointer `u16::max` to `usize`
2-
--> tests/ui/confusing_method_to_numeric_cast.rs:5:13
2+
--> tests/ui/confusing_method_to_numeric_cast.rs:6:13
33
|
44
LL | let _ = u16::max as usize;
55
| ^^^^^^^^^^^^^^^^^
@@ -13,7 +13,7 @@ LL + let _ = u16::MAX as usize;
1313
|
1414

1515
error: casting function pointer `u16::min` to `usize`
16-
--> tests/ui/confusing_method_to_numeric_cast.rs:6:13
16+
--> tests/ui/confusing_method_to_numeric_cast.rs:7:13
1717
|
1818
LL | let _ = u16::min as usize;
1919
| ^^^^^^^^^^^^^^^^^
@@ -25,7 +25,7 @@ LL + let _ = u16::MIN as usize;
2525
|
2626

2727
error: casting function pointer `u16::max_value` to `usize`
28-
--> tests/ui/confusing_method_to_numeric_cast.rs:7:13
28+
--> tests/ui/confusing_method_to_numeric_cast.rs:8:13
2929
|
3030
LL | let _ = u16::max_value as usize;
3131
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -37,7 +37,7 @@ LL + let _ = u16::MAX as usize;
3737
|
3838

3939
error: casting function pointer `u16::min_value` to `usize`
40-
--> tests/ui/confusing_method_to_numeric_cast.rs:8:13
40+
--> tests/ui/confusing_method_to_numeric_cast.rs:9:13
4141
|
4242
LL | let _ = u16::min_value as usize;
4343
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -49,7 +49,7 @@ LL + let _ = u16::MIN as usize;
4949
|
5050

5151
error: casting function pointer `f32::maximum` to `usize`
52-
--> tests/ui/confusing_method_to_numeric_cast.rs:10:13
52+
--> tests/ui/confusing_method_to_numeric_cast.rs:11:13
5353
|
5454
LL | let _ = f32::maximum as usize;
5555
| ^^^^^^^^^^^^^^^^^^^^^
@@ -61,7 +61,7 @@ LL + let _ = f32::MAX as usize;
6161
|
6262

6363
error: casting function pointer `f32::max` to `usize`
64-
--> tests/ui/confusing_method_to_numeric_cast.rs:11:13
64+
--> tests/ui/confusing_method_to_numeric_cast.rs:12:13
6565
|
6666
LL | let _ = f32::max as usize;
6767
| ^^^^^^^^^^^^^^^^^
@@ -73,7 +73,7 @@ LL + let _ = f32::MAX as usize;
7373
|
7474

7575
error: casting function pointer `f32::minimum` to `usize`
76-
--> tests/ui/confusing_method_to_numeric_cast.rs:12:13
76+
--> tests/ui/confusing_method_to_numeric_cast.rs:13:13
7777
|
7878
LL | let _ = f32::minimum as usize;
7979
| ^^^^^^^^^^^^^^^^^^^^^
@@ -85,7 +85,7 @@ LL + let _ = f32::MIN as usize;
8585
|
8686

8787
error: casting function pointer `f32::min` to `usize`
88-
--> tests/ui/confusing_method_to_numeric_cast.rs:13:13
88+
--> tests/ui/confusing_method_to_numeric_cast.rs:14:13
8989
|
9090
LL | let _ = f32::min as usize;
9191
| ^^^^^^^^^^^^^^^^^

src/tools/clippy/tests/ui/derive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#![expect(incomplete_features)] // `unsafe_fields` is incomplete for the time being
1010
#![feature(unsafe_fields)] // `clone()` cannot be derived automatically on unsafe fields
1111

12-
1312
#[derive(Copy)]
1413
struct Qux;
1514

src/tools/clippy/tests/ui/derive.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: you are implementing `Clone` explicitly on a `Copy` type
2-
--> tests/ui/derive.rs:16:1
2+
--> tests/ui/derive.rs:15:1
33
|
44
LL | / impl Clone for Qux {
55
LL | |
@@ -10,7 +10,7 @@ LL | | }
1010
| |_^
1111
|
1212
note: consider deriving `Clone` or removing `Copy`
13-
--> tests/ui/derive.rs:16:1
13+
--> tests/ui/derive.rs:15:1
1414
|
1515
LL | / impl Clone for Qux {
1616
LL | |
@@ -23,7 +23,7 @@ LL | | }
2323
= help: to override `-D warnings` add `#[allow(clippy::expl_impl_clone_on_copy)]`
2424

2525
error: you are implementing `Clone` explicitly on a `Copy` type
26-
--> tests/ui/derive.rs:42:1
26+
--> tests/ui/derive.rs:41:1
2727
|
2828
LL | / impl<'a> Clone for Lt<'a> {
2929
LL | |
@@ -34,7 +34,7 @@ LL | | }
3434
| |_^
3535
|
3636
note: consider deriving `Clone` or removing `Copy`
37-
--> tests/ui/derive.rs:42:1
37+
--> tests/ui/derive.rs:41:1
3838
|
3939
LL | / impl<'a> Clone for Lt<'a> {
4040
LL | |
@@ -45,7 +45,7 @@ LL | | }
4545
| |_^
4646

4747
error: you are implementing `Clone` explicitly on a `Copy` type
48-
--> tests/ui/derive.rs:55:1
48+
--> tests/ui/derive.rs:54:1
4949
|
5050
LL | / impl Clone for BigArray {
5151
LL | |
@@ -56,7 +56,7 @@ LL | | }
5656
| |_^
5757
|
5858
note: consider deriving `Clone` or removing `Copy`
59-
--> tests/ui/derive.rs:55:1
59+
--> tests/ui/derive.rs:54:1
6060
|
6161
LL | / impl Clone for BigArray {
6262
LL | |
@@ -67,7 +67,7 @@ LL | | }
6767
| |_^
6868

6969
error: you are implementing `Clone` explicitly on a `Copy` type
70-
--> tests/ui/derive.rs:68:1
70+
--> tests/ui/derive.rs:67:1
7171
|
7272
LL | / impl Clone for FnPtr {
7373
LL | |
@@ -78,7 +78,7 @@ LL | | }
7878
| |_^
7979
|
8080
note: consider deriving `Clone` or removing `Copy`
81-
--> tests/ui/derive.rs:68:1
81+
--> tests/ui/derive.rs:67:1
8282
|
8383
LL | / impl Clone for FnPtr {
8484
LL | |
@@ -89,7 +89,7 @@ LL | | }
8989
| |_^
9090

9191
error: you are implementing `Clone` explicitly on a `Copy` type
92-
--> tests/ui/derive.rs:90:1
92+
--> tests/ui/derive.rs:89:1
9393
|
9494
LL | / impl<T: Clone> Clone for Generic2<T> {
9595
LL | |
@@ -100,7 +100,7 @@ LL | | }
100100
| |_^
101101
|
102102
note: consider deriving `Clone` or removing `Copy`
103-
--> tests/ui/derive.rs:90:1
103+
--> tests/ui/derive.rs:89:1
104104
|
105105
LL | / impl<T: Clone> Clone for Generic2<T> {
106106
LL | |

src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: casting function pointer `foo` to `i8`, which truncates the value
2-
--> tests/ui/fn_to_numeric_cast.rs:12:13
2+
--> tests/ui/fn_to_numeric_cast.rs:13:13
33
|
44
LL | let _ = foo as i8;
55
| ^^^^^^^^^ help: try: `foo as usize`
@@ -8,19 +8,19 @@ LL | let _ = foo as i8;
88
= help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`
99

1010
error: casting function pointer `foo` to `i16`, which truncates the value
11-
--> tests/ui/fn_to_numeric_cast.rs:14:13
11+
--> tests/ui/fn_to_numeric_cast.rs:15:13
1212
|
1313
LL | let _ = foo as i16;
1414
| ^^^^^^^^^^ help: try: `foo as usize`
1515

1616
error: casting function pointer `foo` to `i32`, which truncates the value
17-
--> tests/ui/fn_to_numeric_cast.rs:16:13
17+
--> tests/ui/fn_to_numeric_cast.rs:17:13
1818
|
1919
LL | let _ = foo as i32;
2020
| ^^^^^^^^^^ help: try: `foo as usize`
2121

2222
error: casting function pointer `foo` to `i64`
23-
--> tests/ui/fn_to_numeric_cast.rs:19:13
23+
--> tests/ui/fn_to_numeric_cast.rs:20:13
2424
|
2525
LL | let _ = foo as i64;
2626
| ^^^^^^^^^^ help: try: `foo as usize`
@@ -29,115 +29,115 @@ LL | let _ = foo as i64;
2929
= help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`
3030

3131
error: casting function pointer `foo` to `i128`
32-
--> tests/ui/fn_to_numeric_cast.rs:21:13
32+
--> tests/ui/fn_to_numeric_cast.rs:22:13
3333
|
3434
LL | let _ = foo as i128;
3535
| ^^^^^^^^^^^ help: try: `foo as usize`
3636

3737
error: casting function pointer `foo` to `isize`
38-
--> tests/ui/fn_to_numeric_cast.rs:23:13
38+
--> tests/ui/fn_to_numeric_cast.rs:24:13
3939
|
4040
LL | let _ = foo as isize;
4141
| ^^^^^^^^^^^^ help: try: `foo as usize`
4242

4343
error: casting function pointer `foo` to `u8`, which truncates the value
44-
--> tests/ui/fn_to_numeric_cast.rs:26:13
44+
--> tests/ui/fn_to_numeric_cast.rs:27:13
4545
|
4646
LL | let _ = foo as u8;
4747
| ^^^^^^^^^ help: try: `foo as usize`
4848

4949
error: casting function pointer `foo` to `u16`, which truncates the value
50-
--> tests/ui/fn_to_numeric_cast.rs:28:13
50+
--> tests/ui/fn_to_numeric_cast.rs:29:13
5151
|
5252
LL | let _ = foo as u16;
5353
| ^^^^^^^^^^ help: try: `foo as usize`
5454

5555
error: casting function pointer `foo` to `u32`, which truncates the value
56-
--> tests/ui/fn_to_numeric_cast.rs:30:13
56+
--> tests/ui/fn_to_numeric_cast.rs:31:13
5757
|
5858
LL | let _ = foo as u32;
5959
| ^^^^^^^^^^ help: try: `foo as usize`
6060

6161
error: casting function pointer `foo` to `u64`
62-
--> tests/ui/fn_to_numeric_cast.rs:33:13
62+
--> tests/ui/fn_to_numeric_cast.rs:34:13
6363
|
6464
LL | let _ = foo as u64;
6565
| ^^^^^^^^^^ help: try: `foo as usize`
6666

6767
error: casting function pointer `foo` to `u128`
68-
--> tests/ui/fn_to_numeric_cast.rs:35:13
68+
--> tests/ui/fn_to_numeric_cast.rs:36:13
6969
|
7070
LL | let _ = foo as u128;
7171
| ^^^^^^^^^^^ help: try: `foo as usize`
7272

7373
error: casting function pointer `abc` to `i8`, which truncates the value
74-
--> tests/ui/fn_to_numeric_cast.rs:49:13
74+
--> tests/ui/fn_to_numeric_cast.rs:50:13
7575
|
7676
LL | let _ = abc as i8;
7777
| ^^^^^^^^^ help: try: `abc as usize`
7878

7979
error: casting function pointer `abc` to `i16`, which truncates the value
80-
--> tests/ui/fn_to_numeric_cast.rs:51:13
80+
--> tests/ui/fn_to_numeric_cast.rs:52:13
8181
|
8282
LL | let _ = abc as i16;
8383
| ^^^^^^^^^^ help: try: `abc as usize`
8484

8585
error: casting function pointer `abc` to `i32`, which truncates the value
86-
--> tests/ui/fn_to_numeric_cast.rs:53:13
86+
--> tests/ui/fn_to_numeric_cast.rs:54:13
8787
|
8888
LL | let _ = abc as i32;
8989
| ^^^^^^^^^^ help: try: `abc as usize`
9090

9191
error: casting function pointer `abc` to `i64`
92-
--> tests/ui/fn_to_numeric_cast.rs:56:13
92+
--> tests/ui/fn_to_numeric_cast.rs:57:13
9393
|
9494
LL | let _ = abc as i64;
9595
| ^^^^^^^^^^ help: try: `abc as usize`
9696

9797
error: casting function pointer `abc` to `i128`
98-
--> tests/ui/fn_to_numeric_cast.rs:58:13
98+
--> tests/ui/fn_to_numeric_cast.rs:59:13
9999
|
100100
LL | let _ = abc as i128;
101101
| ^^^^^^^^^^^ help: try: `abc as usize`
102102

103103
error: casting function pointer `abc` to `isize`
104-
--> tests/ui/fn_to_numeric_cast.rs:60:13
104+
--> tests/ui/fn_to_numeric_cast.rs:61:13
105105
|
106106
LL | let _ = abc as isize;
107107
| ^^^^^^^^^^^^ help: try: `abc as usize`
108108

109109
error: casting function pointer `abc` to `u8`, which truncates the value
110-
--> tests/ui/fn_to_numeric_cast.rs:63:13
110+
--> tests/ui/fn_to_numeric_cast.rs:64:13
111111
|
112112
LL | let _ = abc as u8;
113113
| ^^^^^^^^^ help: try: `abc as usize`
114114

115115
error: casting function pointer `abc` to `u16`, which truncates the value
116-
--> tests/ui/fn_to_numeric_cast.rs:65:13
116+
--> tests/ui/fn_to_numeric_cast.rs:66:13
117117
|
118118
LL | let _ = abc as u16;
119119
| ^^^^^^^^^^ help: try: `abc as usize`
120120

121121
error: casting function pointer `abc` to `u32`, which truncates the value
122-
--> tests/ui/fn_to_numeric_cast.rs:67:13
122+
--> tests/ui/fn_to_numeric_cast.rs:68:13
123123
|
124124
LL | let _ = abc as u32;
125125
| ^^^^^^^^^^ help: try: `abc as usize`
126126

127127
error: casting function pointer `abc` to `u64`
128-
--> tests/ui/fn_to_numeric_cast.rs:70:13
128+
--> tests/ui/fn_to_numeric_cast.rs:71:13
129129
|
130130
LL | let _ = abc as u64;
131131
| ^^^^^^^^^^ help: try: `abc as usize`
132132

133133
error: casting function pointer `abc` to `u128`
134-
--> tests/ui/fn_to_numeric_cast.rs:72:13
134+
--> tests/ui/fn_to_numeric_cast.rs:73:13
135135
|
136136
LL | let _ = abc as u128;
137137
| ^^^^^^^^^^^ help: try: `abc as usize`
138138

139139
error: casting function pointer `f` to `i32`, which truncates the value
140-
--> tests/ui/fn_to_numeric_cast.rs:80:5
140+
--> tests/ui/fn_to_numeric_cast.rs:81:5
141141
|
142142
LL | f as i32
143143
| ^^^^^^^^ help: try: `f as usize`

src/tools/clippy/tests/ui/fn_to_numeric_cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//@[64bit]ignore-bitwidth: 32
44
//@no-rustfix
55
#![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
6+
#![allow(function_casts_as_integer)]
67

78
fn foo() -> String {
89
String::new()

src/tools/clippy/tests/ui/fn_to_numeric_cast_any.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![warn(clippy::fn_to_numeric_cast_any)]
22
#![allow(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
3+
#![allow(function_casts_as_integer)]
34
//@no-rustfix
45
fn foo() -> u8 {
56
0

0 commit comments

Comments
 (0)