From 0ff710798f5b6558a4eb0a2a52b7feb38e6b0d9a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 21 Jul 2026 20:38:55 +0800 Subject: feat(mlint): support multiple suggestions per report Replace the single optional `suggestion` field with a `Vec` to allow multiple automatic fix suggestions per lint report BREAKING CHANGE: The `suggestion` field has been replaced by `suggestions` --- mingling_cli/src/linter/mlint_report.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mingling_cli/src/linter/mlint_report.rs') diff --git a/mingling_cli/src/linter/mlint_report.rs b/mingling_cli/src/linter/mlint_report.rs index 8195f77..0472056 100644 --- a/mingling_cli/src/linter/mlint_report.rs +++ b/mingling_cli/src/linter/mlint_report.rs @@ -51,8 +51,8 @@ pub struct MlintReport { /// Compilation target source file path that this report belongs to pub target_src_path: Option, - /// A suggestion for automatic fix (shown as diff in annotated output) - pub suggestion: Option, + /// Suggestions for automatic fix (shown as diff in annotated output) + pub suggestions: Vec, } /// Report severity level, indicating the seriousness of the Lint result. @@ -248,8 +248,8 @@ impl MlintReport { group = group.element(msg); } - // Render suggestion as a diff (Element::Suggestion) - if let Some(sugg) = &self.suggestion { + // Render suggestions as diffs + for sugg in &self.suggestions { let patch_snippet = Snippet::source(sugg.source.clone()) .line_start(sugg.line_start) .path(&self.file_name) @@ -404,8 +404,8 @@ impl MlintReport { .collect::>(), ) .label(span.label.clone()) - .suggested_replacement(self.suggestion.as_ref().map(|s| s.replacement.clone())) - .suggestion_applicability(if self.suggestion.is_some() { + .suggested_replacement(self.suggestions.first().map(|s| s.replacement.clone())) + .suggestion_applicability(if !self.suggestions.is_empty() { Some(cargo_metadata::diagnostic::Applicability::MachineApplicable) } else { None -- cgit