mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Created lint
This commit is contained in:
parent
9fdcb13edb
commit
7e843515d9
5 changed files with 45 additions and 0 deletions
|
@ -1555,6 +1555,7 @@ Released 2018-09-13
|
||||||
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
|
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
|
||||||
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
|
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
|
||||||
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
|
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
|
||||||
|
[`sort_by_key_reverse`]: https://rust-lang.github.io/rust-clippy/master/index.html#sort_by_key_reverse
|
||||||
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
|
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
|
||||||
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
|
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
|
||||||
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
|
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
|
||||||
|
|
|
@ -304,6 +304,7 @@ 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 sort_by_key_reverse;
|
||||||
mod strings;
|
mod strings;
|
||||||
mod suspicious_trait_impl;
|
mod suspicious_trait_impl;
|
||||||
mod swap;
|
mod swap;
|
||||||
|
@ -779,6 +780,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||||
&shadow::SHADOW_UNRELATED,
|
&shadow::SHADOW_UNRELATED,
|
||||||
&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
|
&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
|
||||||
&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
|
&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
|
||||||
|
&sort_by_key_reverse::SORT_BY_KEY_REVERSE,
|
||||||
&strings::STRING_ADD,
|
&strings::STRING_ADD,
|
||||||
&strings::STRING_ADD_ASSIGN,
|
&strings::STRING_ADD_ASSIGN,
|
||||||
&strings::STRING_LIT_AS_BYTES,
|
&strings::STRING_LIT_AS_BYTES,
|
||||||
|
@ -1391,6 +1393,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||||
LintId::of(&serde_api::SERDE_API_MISUSE),
|
LintId::of(&serde_api::SERDE_API_MISUSE),
|
||||||
LintId::of(&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
|
LintId::of(&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
|
||||||
LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
|
LintId::of(&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
|
||||||
|
LintId::of(&sort_by_key_reverse::SORT_BY_KEY_REVERSE),
|
||||||
LintId::of(&strings::STRING_LIT_AS_BYTES),
|
LintId::of(&strings::STRING_LIT_AS_BYTES),
|
||||||
LintId::of(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
|
LintId::of(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
|
||||||
LintId::of(&suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
|
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:
|
||||||
LintId::of(&ranges::RANGE_ZIP_WITH_LEN),
|
LintId::of(&ranges::RANGE_ZIP_WITH_LEN),
|
||||||
LintId::of(&reference::DEREF_ADDROF),
|
LintId::of(&reference::DEREF_ADDROF),
|
||||||
LintId::of(&reference::REF_IN_DEREF),
|
LintId::of(&reference::REF_IN_DEREF),
|
||||||
|
LintId::of(&sort_by_key_reverse::SORT_BY_KEY_REVERSE),
|
||||||
LintId::of(&swap::MANUAL_SWAP),
|
LintId::of(&swap::MANUAL_SWAP),
|
||||||
LintId::of(&temporary_assignment::TEMPORARY_ASSIGNMENT),
|
LintId::of(&temporary_assignment::TEMPORARY_ASSIGNMENT),
|
||||||
LintId::of(&transmute::CROSSPOINTER_TRANSMUTE),
|
LintId::of(&transmute::CROSSPOINTER_TRANSMUTE),
|
||||||
|
|
28
clippy_lints/src/sort_by_key_reverse.rs
Normal file
28
clippy_lints/src/sort_by_key_reverse.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
use rustc_lint::{LateLintPass, LateContext};
|
||||||
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
use rustc_hir::*;
|
||||||
|
|
||||||
|
declare_clippy_lint! {
|
||||||
|
/// **What it does:**
|
||||||
|
///
|
||||||
|
/// **Why is this bad?**
|
||||||
|
///
|
||||||
|
/// **Known problems:** None.
|
||||||
|
///
|
||||||
|
/// **Example:**
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// // example code where clippy issues a warning
|
||||||
|
/// ```
|
||||||
|
/// Use instead:
|
||||||
|
/// ```rust
|
||||||
|
/// // example code which does not raise clippy warning
|
||||||
|
/// ```
|
||||||
|
pub SORT_BY_KEY_REVERSE,
|
||||||
|
complexity,
|
||||||
|
"default lint description"
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_lint_pass!(SortByKeyReverse => [SORT_BY_KEY_REVERSE]);
|
||||||
|
|
||||||
|
impl LateLintPass<'_, '_> for SortByKeyReverse {}
|
|
@ -1984,6 +1984,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
|
||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "slow_vector_initialization",
|
module: "slow_vector_initialization",
|
||||||
},
|
},
|
||||||
|
Lint {
|
||||||
|
name: "sort_by_key_reverse",
|
||||||
|
group: "complexity",
|
||||||
|
desc: "default lint description",
|
||||||
|
deprecation: None,
|
||||||
|
module: "sort_by_key_reverse",
|
||||||
|
},
|
||||||
Lint {
|
Lint {
|
||||||
name: "string_add",
|
name: "string_add",
|
||||||
group: "restriction",
|
group: "restriction",
|
||||||
|
|
5
tests/ui/sort_by_key_reverse.rs
Normal file
5
tests/ui/sort_by_key_reverse.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#![warn(clippy::sort_by_key_reverse)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// test code goes here
|
||||||
|
}
|
Loading…
Reference in a new issue