mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Updated test cases and formatted
This commit is contained in:
parent
015ab9f925
commit
20cb512e81
4 changed files with 9 additions and 19 deletions
|
@ -304,7 +304,6 @@ mod serde_api;
|
||||||
mod shadow;
|
mod shadow;
|
||||||
mod single_component_path_imports;
|
mod single_component_path_imports;
|
||||||
mod slow_vector_initialization;
|
mod slow_vector_initialization;
|
||||||
mod unnecessary_sort_by;
|
|
||||||
mod strings;
|
mod strings;
|
||||||
mod suspicious_trait_impl;
|
mod suspicious_trait_impl;
|
||||||
mod swap;
|
mod swap;
|
||||||
|
@ -319,6 +318,7 @@ mod try_err;
|
||||||
mod types;
|
mod types;
|
||||||
mod unicode;
|
mod unicode;
|
||||||
mod unnamed_address;
|
mod unnamed_address;
|
||||||
|
mod unnecessary_sort_by;
|
||||||
mod unsafe_removed_from_name;
|
mod unsafe_removed_from_name;
|
||||||
mod unused_io_amount;
|
mod unused_io_amount;
|
||||||
mod unused_self;
|
mod unused_self;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![warn(clippy::sort_by_key)]
|
|
||||||
|
|
||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
#![warn(clippy::sort_by_key_reverse)]
|
|
||||||
|
|
||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
|
|
||||||
|
|
|
@ -1,48 +1,40 @@
|
||||||
error: use Vec::sort here instead
|
error: use Vec::sort here instead
|
||||||
--> $DIR/sort_by_key.rs:13:5
|
--> $DIR/unnecessary_sort_by.rs:12:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| a.cmp(b));
|
LL | vec.sort_by(|a, b| a.cmp(b));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()`
|
||||||
|
|
|
|
||||||
= note: `-D clippy::sort-by-key` implied by `-D warnings`
|
= note: `-D clippy::unnecessary-sort-by` implied by `-D warnings`
|
||||||
|
|
||||||
error: use Vec::sort_by_key here instead
|
error: use Vec::sort_by_key here instead
|
||||||
--> $DIR/sort_by_key.rs:14:5
|
--> $DIR/unnecessary_sort_by.rs:13:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs()));
|
LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs()));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| (a + 5).abs())`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| (a + 5).abs())`
|
||||||
|
|
||||||
error: use Vec::sort_by_key here instead
|
error: use Vec::sort_by_key here instead
|
||||||
--> $DIR/sort_by_key.rs:15:5
|
--> $DIR/unnecessary_sort_by.rs:14:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| id(-a).cmp(&id(-b)));
|
LL | vec.sort_by(|a, b| id(-a).cmp(&id(-b)));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| id(-a))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&a| id(-a))`
|
||||||
|
|
||||||
error: use Vec::sort_by_key here instead
|
error: use Vec::sort_by_key here instead
|
||||||
--> $DIR/sort_by_key.rs:17:5
|
--> $DIR/unnecessary_sort_by.rs:16:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| b.cmp(a));
|
LL | vec.sort_by(|a, b| b.cmp(a));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(b))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(b))`
|
||||||
|
|
||||||
error: use Vec::sort_by_key here instead
|
error: use Vec::sort_by_key here instead
|
||||||
--> $DIR/sort_by_key.rs:18:5
|
--> $DIR/unnecessary_sort_by.rs:17:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs()));
|
LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs()));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse((b + 5).abs()))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse((b + 5).abs()))`
|
||||||
|
|
||||||
error: use Vec::sort_by_key here instead
|
error: use Vec::sort_by_key here instead
|
||||||
--> $DIR/sort_by_key.rs:19:5
|
--> $DIR/unnecessary_sort_by.rs:18:5
|
||||||
|
|
|
|
||||||
LL | vec.sort_by(|a, b| id(-b).cmp(&id(-a)));
|
LL | vec.sort_by(|a, b| id(-b).cmp(&id(-a)));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(id(-b)))`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|&b| Reverse(id(-b)))`
|
||||||
|
|
||||||
error: unknown clippy lint: clippy::sort_by_key_reverse
|
error: aborting due to 6 previous errors
|
||||||
--> $DIR/sort_by_key.rs:2:9
|
|
||||||
|
|
|
||||||
LL | #![warn(clippy::sort_by_key_reverse)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::sort_by_key`
|
|
||||||
|
|
|
||||||
= note: `-D clippy::unknown-clippy-lints` implied by `-D warnings`
|
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue