Skip to content

Commit d7d6b41

Browse files
fix: use more descriptive name
min_max make people think about minmax
1 parent 021cfbf commit d7d6b41

8 files changed

+39
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5800,7 +5800,7 @@ Released 2018-09-13
58005800
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
58015801
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
58025802
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
5803-
[`unnecessary_min_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_max
5803+
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
58045804
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
58055805
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
58065806
[`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
467467
crate::methods::UNNECESSARY_JOIN_INFO,
468468
crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO,
469469
crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
470-
crate::methods::UNNECESSARY_MIN_MAX_INFO,
470+
crate::methods::UNNECESSARY_MIN_OR_MAX_INFO,
471471
crate::methods::UNNECESSARY_RESULT_MAP_OR_ELSE_INFO,
472472
crate::methods::UNNECESSARY_SORT_BY_INFO,
473473
crate::methods::UNNECESSARY_TO_OWNED_INFO,

clippy_lints/src/methods/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mod unnecessary_iter_cloned;
116116
mod unnecessary_join;
117117
mod unnecessary_lazy_eval;
118118
mod unnecessary_literal_unwrap;
119-
mod unnecessary_min_max;
119+
mod unnecessary_min_or_max;
120120
mod unnecessary_result_map_or_else;
121121
mod unnecessary_sort_by;
122122
mod unnecessary_to_owned;
@@ -3991,7 +3991,7 @@ declare_clippy_lint! {
39913991
/// let _ = 0;
39923992
/// ```
39933993
#[clippy::version = "1.78.0"]
3994-
pub UNNECESSARY_MIN_MAX,
3994+
pub UNNECESSARY_MIN_OR_MAX,
39953995
complexity,
39963996
"using 'min()/max()' when there is no need for it"
39973997
}
@@ -4271,7 +4271,7 @@ impl_lint_pass!(Methods => [
42714271
UNNECESSARY_RESULT_MAP_OR_ELSE,
42724272
MANUAL_C_STR_LITERALS,
42734273
UNNECESSARY_GET_THEN_CHECK,
4274-
UNNECESSARY_MIN_MAX,
4274+
UNNECESSARY_MIN_OR_MAX,
42754275
]);
42764276

42774277
/// Extracts a method call name, args, and `Span` of the method name.
@@ -4562,7 +4562,7 @@ impl Methods {
45624562
Some(("bytes", recv2, [], _, _)) => bytes_count_to_len::check(cx, expr, recv, recv2),
45634563
_ => {},
45644564
},
4565-
("min" | "max", [arg]) => unnecessary_min_max::check(cx, expr, name, recv, arg),
4565+
("min" | "max", [arg]) => unnecessary_min_or_max::check(cx, expr, name, recv, arg),
45664566
("drain", ..) => {
45674567
if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.parent_hir_node(expr.hir_id)
45684568
&& matches!(kind, StmtKind::Semi(_))

clippy_lints/src/methods/unnecessary_min_max.rs renamed to clippy_lints/src/methods/unnecessary_min_or_max.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::cmp::Ordering;
22

3-
use super::UNNECESSARY_MIN_MAX;
3+
use super::UNNECESSARY_MIN_OR_MAX;
44
use clippy_utils::diagnostics::span_lint_and_sugg;
55

66
use clippy_utils::consts::{constant, Constant, FullInt};
@@ -54,7 +54,7 @@ fn lint(cx: &LateContext<'_>, expr: &Expr<'_>, name: &str, lhs: Span, rhs: Span,
5454

5555
span_lint_and_sugg(
5656
cx,
57-
UNNECESSARY_MIN_MAX,
57+
UNNECESSARY_MIN_OR_MAX,
5858
expr.span,
5959
format!(
6060
"`{}` is never {} than `{}` and has therefore no effect",

tests/ui/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#![allow(
1313
clippy::cast_abs_to_unsigned,
1414
clippy::no_effect,
15-
clippy::unnecessary_min_max,
15+
clippy::unnecessary_min_or_max,
1616
clippy::unnecessary_operation,
1717
clippy::unnecessary_literal_unwrap
1818
)]

tests/ui/unnecessary_min_max.fixed renamed to tests/ui/unnecessary_min_or_max.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(unused)]
2-
#![warn(clippy::unnecessary_min_max)]
2+
#![warn(clippy::unnecessary_min_or_max)]
33
fn main() {
44
// Both are Literals
55
let _ = (-6_i32);

tests/ui/unnecessary_min_max.rs renamed to tests/ui/unnecessary_min_or_max.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(unused)]
2-
#![warn(clippy::unnecessary_min_max)]
2+
#![warn(clippy::unnecessary_min_or_max)]
33
fn main() {
44
// Both are Literals
55
let _ = (-6_i32).min(9);

tests/ui/unnecessary_min_max.stderr renamed to tests/ui/unnecessary_min_or_max.stderr

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,158 @@
11
error: `(-6_i32)` is never greater than `9` and has therefore no effect
2-
--> tests/ui/unnecessary_min_max.rs:5:13
2+
--> tests/ui/unnecessary_min_or_max.rs:5:13
33
|
44
LL | let _ = (-6_i32).min(9);
55
| ^^^^^^^^^^^^^^^ help: try: `(-6_i32)`
66
|
7-
= note: `-D clippy::unnecessary-min-max` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_min_max)]`
7+
= note: `-D clippy::unnecessary-min-or-max` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_min_or_max)]`
99

1010
error: `(-6_i32)` is never greater than `9` and has therefore no effect
11-
--> tests/ui/unnecessary_min_max.rs:6:13
11+
--> tests/ui/unnecessary_min_or_max.rs:6:13
1212
|
1313
LL | let _ = (-6_i32).max(9);
1414
| ^^^^^^^^^^^^^^^ help: try: `9`
1515

1616
error: `9_u32` is never smaller than `6` and has therefore no effect
17-
--> tests/ui/unnecessary_min_max.rs:7:13
17+
--> tests/ui/unnecessary_min_or_max.rs:7:13
1818
|
1919
LL | let _ = 9_u32.min(6);
2020
| ^^^^^^^^^^^^ help: try: `6`
2121

2222
error: `9_u32` is never smaller than `6` and has therefore no effect
23-
--> tests/ui/unnecessary_min_max.rs:8:13
23+
--> tests/ui/unnecessary_min_or_max.rs:8:13
2424
|
2525
LL | let _ = 9_u32.max(6);
2626
| ^^^^^^^^^^^^ help: try: `9_u32`
2727

2828
error: `6` is never greater than `7_u8` and has therefore no effect
29-
--> tests/ui/unnecessary_min_max.rs:9:13
29+
--> tests/ui/unnecessary_min_or_max.rs:9:13
3030
|
3131
LL | let _ = 6.min(7_u8);
3232
| ^^^^^^^^^^^ help: try: `6`
3333

3434
error: `6` is never greater than `7_u8` and has therefore no effect
35-
--> tests/ui/unnecessary_min_max.rs:10:13
35+
--> tests/ui/unnecessary_min_or_max.rs:10:13
3636
|
3737
LL | let _ = 6.max(7_u8);
3838
| ^^^^^^^^^^^ help: try: `7_u8`
3939

4040
error: `i32::MIN` is never greater than `x` and has therefore no effect
41-
--> tests/ui/unnecessary_min_max.rs:14:13
41+
--> tests/ui/unnecessary_min_or_max.rs:14:13
4242
|
4343
LL | let _ = i32::MIN.min(x);
4444
| ^^^^^^^^^^^^^^^ help: try: `i32::MIN`
4545

4646
error: `i32::MIN` is never greater than `x` and has therefore no effect
47-
--> tests/ui/unnecessary_min_max.rs:15:13
47+
--> tests/ui/unnecessary_min_or_max.rs:15:13
4848
|
4949
LL | let _ = i32::MIN.max(x);
5050
| ^^^^^^^^^^^^^^^ help: try: `x`
5151

5252
error: `x` is never smaller than `i32::MIN` and has therefore no effect
53-
--> tests/ui/unnecessary_min_max.rs:16:13
53+
--> tests/ui/unnecessary_min_or_max.rs:16:13
5454
|
5555
LL | let _ = x.min(i32::MIN);
5656
| ^^^^^^^^^^^^^^^ help: try: `i32::MIN`
5757

5858
error: `x` is never smaller than `i32::MIN` and has therefore no effect
59-
--> tests/ui/unnecessary_min_max.rs:17:13
59+
--> tests/ui/unnecessary_min_or_max.rs:17:13
6060
|
6161
LL | let _ = x.max(i32::MIN);
6262
| ^^^^^^^^^^^^^^^ help: try: `x`
6363

6464
error: `i32::MAX` is never smaller than `x` and has therefore no effect
65-
--> tests/ui/unnecessary_min_max.rs:20:13
65+
--> tests/ui/unnecessary_min_or_max.rs:20:13
6666
|
6767
LL | let _ = i32::MAX.min(x);
6868
| ^^^^^^^^^^^^^^^ help: try: `x`
6969

7070
error: `i32::MAX` is never smaller than `x` and has therefore no effect
71-
--> tests/ui/unnecessary_min_max.rs:21:13
71+
--> tests/ui/unnecessary_min_or_max.rs:21:13
7272
|
7373
LL | let _ = i32::MAX.max(x);
7474
| ^^^^^^^^^^^^^^^ help: try: `i32::MAX`
7575

7676
error: `x` is never greater than `i32::MAX` and has therefore no effect
77-
--> tests/ui/unnecessary_min_max.rs:22:13
77+
--> tests/ui/unnecessary_min_or_max.rs:22:13
7878
|
7979
LL | let _ = x.min(i32::MAX);
8080
| ^^^^^^^^^^^^^^^ help: try: `x`
8181

8282
error: `x` is never greater than `i32::MAX` and has therefore no effect
83-
--> tests/ui/unnecessary_min_max.rs:23:13
83+
--> tests/ui/unnecessary_min_or_max.rs:23:13
8484
|
8585
LL | let _ = x.max(i32::MAX);
8686
| ^^^^^^^^^^^^^^^ help: try: `i32::MAX`
8787

8888
error: `u32::MAX` is never smaller than `x` and has therefore no effect
89-
--> tests/ui/unnecessary_min_max.rs:27:13
89+
--> tests/ui/unnecessary_min_or_max.rs:27:13
9090
|
9191
LL | let _ = u32::MAX.min(x);
9292
| ^^^^^^^^^^^^^^^ help: try: `x`
9393

9494
error: `u32::MAX` is never smaller than `x` and has therefore no effect
95-
--> tests/ui/unnecessary_min_max.rs:28:13
95+
--> tests/ui/unnecessary_min_or_max.rs:28:13
9696
|
9797
LL | let _ = u32::MAX.max(x);
9898
| ^^^^^^^^^^^^^^^ help: try: `u32::MAX`
9999

100100
error: `x` is never greater than `u32::MAX` and has therefore no effect
101-
--> tests/ui/unnecessary_min_max.rs:29:13
101+
--> tests/ui/unnecessary_min_or_max.rs:29:13
102102
|
103103
LL | let _ = x.min(u32::MAX);
104104
| ^^^^^^^^^^^^^^^ help: try: `x`
105105

106106
error: `x` is never greater than `u32::MAX` and has therefore no effect
107-
--> tests/ui/unnecessary_min_max.rs:30:13
107+
--> tests/ui/unnecessary_min_or_max.rs:30:13
108108
|
109109
LL | let _ = x.max(u32::MAX);
110110
| ^^^^^^^^^^^^^^^ help: try: `u32::MAX`
111111

112112
error: `u32::MIN` is never greater than `x` and has therefore no effect
113-
--> tests/ui/unnecessary_min_max.rs:33:13
113+
--> tests/ui/unnecessary_min_or_max.rs:33:13
114114
|
115115
LL | let _ = u32::MIN.min(x);
116116
| ^^^^^^^^^^^^^^^ help: try: `u32::MIN`
117117

118118
error: `u32::MIN` is never greater than `x` and has therefore no effect
119-
--> tests/ui/unnecessary_min_max.rs:34:13
119+
--> tests/ui/unnecessary_min_or_max.rs:34:13
120120
|
121121
LL | let _ = u32::MIN.max(x);
122122
| ^^^^^^^^^^^^^^^ help: try: `x`
123123

124124
error: `x` is never smaller than `u32::MIN` and has therefore no effect
125-
--> tests/ui/unnecessary_min_max.rs:35:13
125+
--> tests/ui/unnecessary_min_or_max.rs:35:13
126126
|
127127
LL | let _ = x.min(u32::MIN);
128128
| ^^^^^^^^^^^^^^^ help: try: `u32::MIN`
129129

130130
error: `x` is never smaller than `u32::MIN` and has therefore no effect
131-
--> tests/ui/unnecessary_min_max.rs:36:13
131+
--> tests/ui/unnecessary_min_or_max.rs:36:13
132132
|
133133
LL | let _ = x.max(u32::MIN);
134134
| ^^^^^^^^^^^^^^^ help: try: `x`
135135

136136
error: `0` is never greater than `x` and has therefore no effect
137-
--> tests/ui/unnecessary_min_max.rs:39:13
137+
--> tests/ui/unnecessary_min_or_max.rs:39:13
138138
|
139139
LL | let _ = 0.min(x);
140140
| ^^^^^^^^ help: try: `0`
141141

142142
error: `0` is never greater than `x` and has therefore no effect
143-
--> tests/ui/unnecessary_min_max.rs:40:13
143+
--> tests/ui/unnecessary_min_or_max.rs:40:13
144144
|
145145
LL | let _ = 0.max(x);
146146
| ^^^^^^^^ help: try: `x`
147147

148148
error: `x` is never smaller than `0_u32` and has therefore no effect
149-
--> tests/ui/unnecessary_min_max.rs:41:13
149+
--> tests/ui/unnecessary_min_or_max.rs:41:13
150150
|
151151
LL | let _ = x.min(0_u32);
152152
| ^^^^^^^^^^^^ help: try: `0_u32`
153153

154154
error: `x` is never smaller than `0_u32` and has therefore no effect
155-
--> tests/ui/unnecessary_min_max.rs:42:13
155+
--> tests/ui/unnecessary_min_or_max.rs:42:13
156156
|
157157
LL | let _ = x.max(0_u32);
158158
| ^^^^^^^^^^^^ help: try: `x`

0 commit comments

Comments
 (0)