Skip to content

Commit 20cb512

Browse files
committed
Updated test cases and formatted
1 parent 015ab9f commit 20cb512

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ mod serde_api;
304304
mod shadow;
305305
mod single_component_path_imports;
306306
mod slow_vector_initialization;
307-
mod unnecessary_sort_by;
308307
mod strings;
309308
mod suspicious_trait_impl;
310309
mod swap;
@@ -319,6 +318,7 @@ mod try_err;
319318
mod types;
320319
mod unicode;
321320
mod unnamed_address;
321+
mod unnecessary_sort_by;
322322
mod unsafe_removed_from_name;
323323
mod unused_io_amount;
324324
mod unused_self;

tests/ui/unnecessary_sort_by.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
#![warn(clippy::sort_by_key)]
32

43
use std::cmp::Reverse;
54

tests/ui/unnecessary_sort_by.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
#![warn(clippy::sort_by_key_reverse)]
32

43
use std::cmp::Reverse;
54

tests/ui/unnecessary_sort_by.stderr

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,40 @@
11
error: use Vec::sort here instead
2-
--> $DIR/sort_by_key.rs:13:5
2+
--> $DIR/unnecessary_sort_by.rs:12:5
33
|
44
LL | vec.sort_by(|a, b| a.cmp(b));
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()`
66
|
7-
= note: `-D clippy::sort-by-key` implied by `-D warnings`
7+
= note: `-D clippy::unnecessary-sort-by` implied by `-D warnings`
88

99
error: use Vec::sort_by_key here instead
10-
--> $DIR/sort_by_key.rs:14:5
10+
--> $DIR/unnecessary_sort_by.rs:13:5
1111
|
1212
LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs()));
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| (a + 5).abs())`
1414

1515
error: use Vec::sort_by_key here instead
16-
--> $DIR/sort_by_key.rs:15:5
16+
--> $DIR/unnecessary_sort_by.rs:14:5
1717
|
1818
LL | vec.sort_by(|a, b| id(-a).cmp(&id(-b)));
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| id(-a))`
2020

2121
error: use Vec::sort_by_key here instead
22-
--> $DIR/sort_by_key.rs:17:5
22+
--> $DIR/unnecessary_sort_by.rs:16:5
2323
|
2424
LL | vec.sort_by(|a, b| b.cmp(a));
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(b))`
2626

2727
error: use Vec::sort_by_key here instead
28-
--> $DIR/sort_by_key.rs:18:5
28+
--> $DIR/unnecessary_sort_by.rs:17:5
2929
|
3030
LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs()));
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse((b + 5).abs()))`
3232

3333
error: use Vec::sort_by_key here instead
34-
--> $DIR/sort_by_key.rs:19:5
34+
--> $DIR/unnecessary_sort_by.rs:18:5
3535
|
3636
LL | vec.sort_by(|a, b| id(-b).cmp(&id(-a)));
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(id(-b)))`
3838

39-
error: unknown clippy lint: clippy::sort_by_key_reverse
40-
--> $DIR/sort_by_key.rs:2:9
41-
|
42-
LL | #![warn(clippy::sort_by_key_reverse)]
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::sort_by_key`
44-
|
45-
= note: `-D clippy::unknown-clippy-lints` implied by `-D warnings`
46-
47-
error: aborting due to 7 previous errors
39+
error: aborting due to 6 previous errors
4840

0 commit comments

Comments
 (0)