aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/src/linter/mlint_report.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-21 20:38:55 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-21 20:38:55 +0800
commit0ff710798f5b6558a4eb0a2a52b7feb38e6b0d9a (patch)
tree3b265b80728730952859dc48251af7e575003871 /mingling_cli/src/linter/mlint_report.rs
parentf422d85597ef27a6d6baff7e8cd2efc26541d32e (diff)
feat(mlint): support multiple suggestions per report
Replace the single optional `suggestion` field with a `Vec<LintSuggestion>` to allow multiple automatic fix suggestions per lint report BREAKING CHANGE: The `suggestion` field has been replaced by `suggestions`
Diffstat (limited to 'mingling_cli/src/linter/mlint_report.rs')
-rw-r--r--mingling_cli/src/linter/mlint_report.rs12
1 files changed, 6 insertions, 6 deletions
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<String>,
- /// A suggestion for automatic fix (shown as diff in annotated output)
- pub suggestion: Option<LintSuggestion>,
+ /// Suggestions for automatic fix (shown as diff in annotated output)
+ pub suggestions: Vec<LintSuggestion>,
}
/// 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::<Vec<_>>(),
)
.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