Skip to content

Commit 7e84351

Browse files
committed
Created lint
1 parent 9fdcb13 commit 7e84351

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,7 @@ Released 2018-09-13
15551555
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
15561556
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
15571557
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
1558+
[`sort_by_key_reverse`]: https://rust-lang.github.io/rust-clippy/master/index.html#sort_by_key_reverse
15581559
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
15591560
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
15601561
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign

clippy_lints/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ mod serde_api;
304304
mod shadow;
305305
mod single_component_path_imports;
306306
mod slow_vector_initialization;
307+
mod sort_by_key_reverse;
307308
mod strings;
308309
mod suspicious_trait_impl;
309310
mod swap;
@@ -779,6 +780,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
779780
&shadow::SHADOW_UNRELATED,
780781
&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
781782
&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
783+
&sort_by_key_reverse::SORT_BY_KEY_REVERSE,
782784
&strings::STRING_ADD,
783785
&strings::STRING_ADD_ASSIGN,
784786
&strings::STRING_LIT_AS_BYTES,
@@ -1391,6 +1393,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13911393
LintId::of(&serde_api::SERDE_API_MISUSE),
13921394
LintId::of(&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
13931395
LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
1396+
LintId::of(&sort_by_key_reverse::SORT_BY_KEY_REVERSE),
13941397
LintId::of(&strings::STRING_LIT_AS_BYTES),
13951398
LintId::of(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
13961399
LintId::of(&suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
@@ -1592,6 +1595,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15921595
LintId::of(&ranges::RANGE_ZIP_WITH_LEN),
15931596
LintId::of(&reference::DEREF_ADDROF),
15941597
LintId::of(&reference::REF_IN_DEREF),
1598+
LintId::of(&sort_by_key_reverse::SORT_BY_KEY_REVERSE),
15951599
LintId::of(&swap::MANUAL_SWAP),
15961600
LintId::of(&temporary_assignment::TEMPORARY_ASSIGNMENT),
15971601
LintId::of(&transmute::CROSSPOINTER_TRANSMUTE),
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use rustc_lint::{LateLintPass, LateContext};
2+
use rustc_session::{declare_lint_pass, declare_tool_lint};
3+
use rustc_hir::*;
4+
5+
declare_clippy_lint! {
6+
/// **What it does:**
7+
///
8+
/// **Why is this bad?**
9+
///
10+
/// **Known problems:** None.
11+
///
12+
/// **Example:**
13+
///
14+
/// ```rust
15+
/// // example code where clippy issues a warning
16+
/// ```
17+
/// Use instead:
18+
/// ```rust
19+
/// // example code which does not raise clippy warning
20+
/// ```
21+
pub SORT_BY_KEY_REVERSE,
22+
complexity,
23+
"default lint description"
24+
}
25+
26+
declare_lint_pass!(SortByKeyReverse => [SORT_BY_KEY_REVERSE]);
27+
28+
impl LateLintPass<'_, '_> for SortByKeyReverse {}

src/lintlist/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
19841984
deprecation: None,
19851985
module: "slow_vector_initialization",
19861986
},
1987+
Lint {
1988+
name: "sort_by_key_reverse",
1989+
group: "complexity",
1990+
desc: "default lint description",
1991+
deprecation: None,
1992+
module: "sort_by_key_reverse",
1993+
},
19871994
Lint {
19881995
name: "string_add",
19891996
group: "restriction",

tests/ui/sort_by_key_reverse.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::sort_by_key_reverse)]
2+
3+
fn main() {
4+
// test code goes here
5+
}

0 commit comments

Comments
 (0)