Skip to content

Commit

Permalink
fix: --explain reporting the wrong linter
Browse files Browse the repository at this point in the history
Fixes a regression introduced in 4e4643a.

We want the longest prefixes to be checked first so we of course
have to reverse the sorting when sorting by prefix length.

Fixes #2210.
  • Loading branch information
not-my-profile authored and charliermarsh committed Jan 26, 2023
1 parent bab8691 commit 4f3b63e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ruff_macros/src/rule_namespace.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::Reverse;
use std::collections::HashSet;

use proc_macro2::{Ident, Span};
Expand Down Expand Up @@ -70,7 +71,7 @@ pub fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream>
});
}

parsed.sort_by_key(|(prefix, _)| prefix.len());
parsed.sort_by_key(|(prefix, _)| Reverse(prefix.len()));

let mut if_statements = quote!();
let mut into_iter_match_arms = quote!();
Expand Down

0 comments on commit 4f3b63e

Please sign in to comment.