diff --git a/selene-lib/src/lints.rs b/selene-lib/src/lints.rs index d3ba8989..6f3a1584 100644 --- a/selene-lib/src/lints.rs +++ b/selene-lib/src/lints.rs @@ -137,7 +137,7 @@ impl Diagnostic { if suggestion_str.is_empty() { "consider removing this".to_string() } else { - format!("try: `{}`", suggestion_str) + format!("try: `{suggestion_str}`") }, ); } @@ -196,14 +196,17 @@ impl Diagnostic { } } + #[must_use] pub fn start_position(&self) -> u32 { self.primary_label.range.0 } + #[must_use] pub fn has_machine_applicable_fix(&self) -> bool { self.suggestion.is_some() && self.applicability == Applicability::MachineApplicable } + #[must_use] pub fn has_maybe_incorrect_fix(&self) -> bool { self.suggestion.is_some() && self.applicability == Applicability::MaybeIncorrect } @@ -211,13 +214,13 @@ impl Diagnostic { /// After applying suggestions, calls `get_new_diagnostics` and reruns to ensure fixes didn't produce new errors pub fn get_applied_suggestions_code( code: &str, - diagnostics: Vec<&Diagnostic>, + diagnostics: &[&Diagnostic], get_new_diagnostics: F, ) -> String where F: Fn(&str) -> Vec, { - let mut chosen_diagnostics = Self::get_independent_suggestions(&diagnostics); + let mut chosen_diagnostics = Self::get_independent_suggestions(diagnostics); let mut owned_diagnostics_ref; let mut owned_diagnostics; diff --git a/selene-lib/src/lints/test_util.rs b/selene-lib/src/lints/test_util.rs index 5216d385..c4b2d7c8 100644 --- a/selene-lib/src/lints/test_util.rs +++ b/selene-lib/src/lints/test_util.rs @@ -142,7 +142,7 @@ pub fn test_lint_config_with_output< suggestion = Diagnostic::get_applied_suggestions_code( suggestion.as_str(), - fixed_diagnostics, + &fixed_diagnostics, |new_code| { let fixed_ast = full_moon::parse(new_code).unwrap_or_else(|_| { panic!( diff --git a/selene/src/main.rs b/selene/src/main.rs index 3a640bf8..98f490f5 100644 --- a/selene/src/main.rs +++ b/selene/src/main.rs @@ -297,7 +297,7 @@ fn read( suggestion = Diagnostic::get_applied_suggestions_code( suggestion.as_str(), - diagnostics + &diagnostics .iter() .filter(|diagnostic| diagnostic.diagnostic.has_machine_applicable_fix()) .map(|diagnostic| &diagnostic.diagnostic)