Renamed to
This commit is contained in:
parent
07886a9764
commit
015ab9f925
@ -304,7 +304,7 @@ mod serde_api;
|
||||
mod shadow;
|
||||
mod single_component_path_imports;
|
||||
mod slow_vector_initialization;
|
||||
mod sort_by_key;
|
||||
mod unnecessary_sort_by;
|
||||
mod strings;
|
||||
mod suspicious_trait_impl;
|
||||
mod swap;
|
||||
@ -780,7 +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::SORT_BY_KEY,
|
||||
&unnecessary_sort_by::UNNECESSARY_SORT_BY,
|
||||
&strings::STRING_ADD,
|
||||
&strings::STRING_ADD_ASSIGN,
|
||||
&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 redundant_clone::RedundantClone);
|
||||
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 assertions_on_constants::AssertionsOnConstants);
|
||||
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(&single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
|
||||
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(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_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(&reference::DEREF_ADDROF),
|
||||
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(&temporary_assignment::TEMPORARY_ASSIGNMENT),
|
||||
LintId::of(&transmute::CROSSPOINTER_TRANSMUTE),
|
||||
|
@ -14,9 +14,9 @@ declare_clippy_lint! {
|
||||
/// which compares the two arguments, either directly or indirectly.
|
||||
///
|
||||
/// **Why is this bad?**
|
||||
/// It is more clear to use `Vec::sort_by_key` (or
|
||||
/// `Vec::sort_by_key` and `std::cmp::Reverse` if necessary) than
|
||||
/// using
|
||||
/// It is more clear to use `Vec::sort_by_key` (or `Vec::sort` if
|
||||
/// possible) than to use `Vec::sort_by` and and a more complicated
|
||||
/// closure.
|
||||
///
|
||||
/// **Known problems:** None.
|
||||
///
|
||||
@ -29,12 +29,12 @@ declare_clippy_lint! {
|
||||
/// ```rust
|
||||
/// vec.sort_by_key(|a| a.foo());
|
||||
/// ```
|
||||
pub SORT_BY_KEY,
|
||||
pub UNNECESSARY_SORT_BY,
|
||||
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 {
|
||||
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<'_>) {
|
||||
match detect_lint(cx, expr) {
|
||||
Some(LintTrigger::SortByKey(trigger)) => utils::span_lint_and_sugg(
|
||||
cx,
|
||||
SORT_BY_KEY,
|
||||
UNNECESSARY_SORT_BY,
|
||||
expr.span,
|
||||
"use Vec::sort_by_key here instead",
|
||||
"try",
|
||||
@ -225,7 +225,7 @@ impl LateLintPass<'_, '_> for SortByKey {
|
||||
),
|
||||
Some(LintTrigger::Sort(trigger)) => utils::span_lint_and_sugg(
|
||||
cx,
|
||||
SORT_BY_KEY,
|
||||
UNNECESSARY_SORT_BY,
|
||||
expr.span,
|
||||
"use Vec::sort here instead",
|
||||
"try",
|
Loading…
x
Reference in New Issue
Block a user