Created lint

This commit is contained in:
JarredAllen 2020-05-14 15:06:05 -07:00
parent 9fdcb13edb
commit 7e843515d9
5 changed files with 45 additions and 0 deletions

View file

@ -1555,6 +1555,7 @@ Released 2018-09-13
[`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
[`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
[`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

View file

@ -304,6 +304,7 @@ mod serde_api;
mod shadow;
mod single_component_path_imports;
mod slow_vector_initialization;
mod sort_by_key_reverse;
mod strings;
mod suspicious_trait_impl;
mod swap;
@ -779,6 +780,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&shadow::SHADOW_UNRELATED,
&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
&slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
&sort_by_key_reverse::SORT_BY_KEY_REVERSE,
&strings::STRING_ADD,
&strings::STRING_ADD_ASSIGN,
&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(&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
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(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_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(&reference::DEREF_ADDROF),
LintId::of(&reference::REF_IN_DEREF),
LintId::of(&sort_by_key_reverse::SORT_BY_KEY_REVERSE),
LintId::of(&swap::MANUAL_SWAP),
LintId::of(&temporary_assignment::TEMPORARY_ASSIGNMENT),
LintId::of(&transmute::CROSSPOINTER_TRANSMUTE),

View 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 {}

View file

@ -1984,6 +1984,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
deprecation: None,
module: "slow_vector_initialization",
},
Lint {
name: "sort_by_key_reverse",
group: "complexity",
desc: "default lint description",
deprecation: None,
module: "sort_by_key_reverse",
},
Lint {
name: "string_add",
group: "restriction",

View file

@ -0,0 +1,5 @@
#![warn(clippy::sort_by_key_reverse)]
fn main() {
// test code goes here
}