Renamed to
This commit is contained in:
@@ -304,7 +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;
|
mod unnecessary_sort_by;
|
||||||
mod strings;
|
mod strings;
|
||||||
mod suspicious_trait_impl;
|
mod suspicious_trait_impl;
|
||||||
mod swap;
|
mod swap;
|
||||||
@@ -780,7 +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::SORT_BY_KEY,
|
&unnecessary_sort_by::UNNECESSARY_SORT_BY,
|
||||||
&strings::STRING_ADD,
|
&strings::STRING_ADD,
|
||||||
&strings::STRING_ADD_ASSIGN,
|
&strings::STRING_ADD_ASSIGN,
|
||||||
&strings::STRING_LIT_AS_BYTES,
|
&strings::STRING_LIT_AS_BYTES,
|
||||||
@@ -998,7 +998,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
store.register_late_pass(|| box ptr_offset_with_cast::PtrOffsetWithCast);
|
store.register_late_pass(|| box ptr_offset_with_cast::PtrOffsetWithCast);
|
||||||
store.register_late_pass(|| box redundant_clone::RedundantClone);
|
store.register_late_pass(|| box redundant_clone::RedundantClone);
|
||||||
store.register_late_pass(|| box slow_vector_initialization::SlowVectorInit);
|
store.register_late_pass(|| box slow_vector_initialization::SlowVectorInit);
|
||||||
store.register_late_pass(|| box sort_by_key::SortByKey);
|
store.register_late_pass(|| box unnecessary_sort_by::UnnecessarySortBy);
|
||||||
store.register_late_pass(|| box types::RefToMut);
|
store.register_late_pass(|| box types::RefToMut);
|
||||||
store.register_late_pass(|| box assertions_on_constants::AssertionsOnConstants);
|
store.register_late_pass(|| box assertions_on_constants::AssertionsOnConstants);
|
||||||
store.register_late_pass(|| box missing_const_for_fn::MissingConstForFn);
|
store.register_late_pass(|| box missing_const_for_fn::MissingConstForFn);
|
||||||
@@ -1394,7 +1394,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::SORT_BY_KEY),
|
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
|
||||||
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),
|
||||||
@@ -1596,7 +1596,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::SORT_BY_KEY),
|
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
|
||||||
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),
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare_clippy_lint! {
|
|||||||
/// which compares the two arguments, either directly or indirectly.
|
/// which compares the two arguments, either directly or indirectly.
|
||||||
///
|
///
|
||||||
/// **Why is this bad?**
|
/// **Why is this bad?**
|
||||||
/// It is more clear to use `Vec::sort_by_key` (or
|
/// It is more clear to use `Vec::sort_by_key` (or `Vec::sort` if
|
||||||
/// `Vec::sort_by_key` and `std::cmp::Reverse` if necessary) than
|
/// possible) than to use `Vec::sort_by` and and a more complicated
|
||||||
/// using
|
/// closure.
|
||||||
///
|
///
|
||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
@@ -29,12 +29,12 @@ declare_clippy_lint! {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// vec.sort_by_key(|a| a.foo());
|
/// vec.sort_by_key(|a| a.foo());
|
||||||
/// ```
|
/// ```
|
||||||
pub SORT_BY_KEY,
|
pub UNNECESSARY_SORT_BY,
|
||||||
complexity,
|
complexity,
|
||||||
"Use of `Vec::sort_by` when `Vec::sort_by_key` would be clearer"
|
"Use of `Vec::sort_by` when `Vec::sort_by_key` or `Vec::sort` would be clearer"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint_pass!(SortByKey => [SORT_BY_KEY]);
|
declare_lint_pass!(UnnecessarySortBy => [UNNECESSARY_SORT_BY]);
|
||||||
|
|
||||||
enum LintTrigger {
|
enum LintTrigger {
|
||||||
Sort(SortDetection),
|
Sort(SortDetection),
|
||||||
@@ -205,12 +205,12 @@ fn detect_lint(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<LintTrigger>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LateLintPass<'_, '_> for SortByKey {
|
impl LateLintPass<'_, '_> for UnnecessarySortBy {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
|
||||||
match detect_lint(cx, expr) {
|
match detect_lint(cx, expr) {
|
||||||
Some(LintTrigger::SortByKey(trigger)) => utils::span_lint_and_sugg(
|
Some(LintTrigger::SortByKey(trigger)) => utils::span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
SORT_BY_KEY,
|
UNNECESSARY_SORT_BY,
|
||||||
expr.span,
|
expr.span,
|
||||||
"use Vec::sort_by_key here instead",
|
"use Vec::sort_by_key here instead",
|
||||||
"try",
|
"try",
|
||||||
@@ -225,7 +225,7 @@ impl LateLintPass<'_, '_> for SortByKey {
|
|||||||
),
|
),
|
||||||
Some(LintTrigger::Sort(trigger)) => utils::span_lint_and_sugg(
|
Some(LintTrigger::Sort(trigger)) => utils::span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
SORT_BY_KEY,
|
UNNECESSARY_SORT_BY,
|
||||||
expr.span,
|
expr.span,
|
||||||
"use Vec::sort here instead",
|
"use Vec::sort here instead",
|
||||||
"try",
|
"try",
|
||||||
Reference in New Issue
Block a user