fix: --explain reporting the wrong linter

Fixes a regression introduced in 4e4643aa5d.

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.
This commit is contained in:
Martin Fischer 2023-01-26 19:35:52 +01:00 committed by Charlie Marsh
parent bab8691132
commit 4f3b63edd4
1 changed files with 2 additions and 1 deletions

View File

@ -1,3 +1,4 @@
use std::cmp::Reverse;
use std::collections::HashSet;
use proc_macro2::{Ident, Span};
@ -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!();