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
Auto merge of rust-lang#5429 - faern:use-assoc-int-float-consts, r=flip1995
Use assoc int and float consts instead of module level ones
changelog: Recommend primitive type associated constants instead of module level constants
In Rust 1.43 integer and float primitive types will have a number of new associated constants. For example `MAX`, `MIN` and a number of constants related to the machine representation of floats. rust-lang#68952
These new constants are preferred over the module level constants in `{core,std}::{f*, u*, i*}`. I have in the last few days made sure that the documentation in the main rust repository uses the new constants in every place I could find (rust-lang#69860, rust-lang#70782). So the next step is naturally to make the linter recommend the new constants as well.
This PR only changes two lints. There are more. But I did not want the PR to be too big. And since I have not contributed to clippy before it felt saner to start with a small PR so I see if there are any quirks. More will come later.
Copy file name to clipboardexpand all lines: tests/ui/absurd-extreme-comparisons.stderr
+18-18
Original file line number
Diff line number
Diff line change
@@ -42,34 +42,34 @@ LL | Z > u;
42
42
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
43
43
--> $DIR/absurd-extreme-comparisons.rs:19:5
44
44
|
45
-
LL | u > std::u32::MAX;
46
-
| ^^^^^^^^^^^^^^^^^
45
+
LL | u > u32::MAX;
46
+
| ^^^^^^^^^^^^
47
47
|
48
-
= help: because `std::u32::MAX` is the maximum value for this type, this comparison is always false
48
+
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false
49
49
50
50
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
51
51
--> $DIR/absurd-extreme-comparisons.rs:20:5
52
52
|
53
-
LL | u >= std::u32::MAX;
54
-
| ^^^^^^^^^^^^^^^^^^
53
+
LL | u >= u32::MAX;
54
+
| ^^^^^^^^^^^^^
55
55
|
56
-
= help: because `std::u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == std::u32::MAX` instead
56
+
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == u32::MAX` instead
57
57
58
58
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
59
59
--> $DIR/absurd-extreme-comparisons.rs:21:5
60
60
|
61
-
LL | std::u32::MAX < u;
62
-
| ^^^^^^^^^^^^^^^^^
61
+
LL | u32::MAX < u;
62
+
| ^^^^^^^^^^^^
63
63
|
64
-
= help: because `std::u32::MAX` is the maximum value for this type, this comparison is always false
64
+
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false
65
65
66
66
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
67
67
--> $DIR/absurd-extreme-comparisons.rs:22:5
68
68
|
69
-
LL | std::u32::MAX <= u;
70
-
| ^^^^^^^^^^^^^^^^^^
69
+
LL | u32::MAX <= u;
70
+
| ^^^^^^^^^^^^^
71
71
|
72
-
= help: because `std::u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `std::u32::MAX == u` instead
72
+
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u32::MAX == u` instead
73
73
74
74
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
75
75
--> $DIR/absurd-extreme-comparisons.rs:23:5
@@ -106,18 +106,18 @@ LL | i < -127 - 1;
106
106
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
107
107
--> $DIR/absurd-extreme-comparisons.rs:28:5
108
108
|
109
-
LL | std::i8::MAX >= i;
110
-
| ^^^^^^^^^^^^^^^^^
109
+
LL | i8::MAX >= i;
110
+
| ^^^^^^^^^^^^
111
111
|
112
-
= help: because `std::i8::MAX` is the maximum value for this type, this comparison is always true
112
+
= help: because `i8::MAX` is the maximum value for this type, this comparison is always true
113
113
114
114
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
115
115
--> $DIR/absurd-extreme-comparisons.rs:29:5
116
116
|
117
-
LL | 3-7 < std::i32::MIN;
118
-
| ^^^^^^^^^^^^^^^^^^^
117
+
LL | 3-7 < i32::MIN;
118
+
| ^^^^^^^^^^^^^^
119
119
|
120
-
= help: because `std::i32::MIN` is the minimum value for this type, this comparison is always false
120
+
= help: because `i32::MIN` is the minimum value for this type, this comparison is always false
121
121
122
122
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
0 commit comments