1
Fork 0

Only give autofix suggestion when no named args are present

This commit is contained in:
francorbacho 2023-10-05 15:46:34 +02:00
parent 38b0182832
commit c8ee7db6ea
6 changed files with 44 additions and 6 deletions

View file

@ -657,7 +657,7 @@ pub(crate) struct FormatRedundantArgs {
pub(crate) note: MultiSpan,
#[subdiagnostic]
pub(crate) sugg: FormatRedundantArgsSugg,
pub(crate) sugg: Option<FormatRedundantArgsSugg>,
}
#[derive(Subdiagnostic)]

View file

@ -767,11 +767,17 @@ fn report_redundant_format_arguments<'a>(
suggestion_spans.push(span);
}
let sugg = if args.named_args().len() == 0 {
Some(errors::FormatRedundantArgsSugg { spans: suggestion_spans })
} else {
None
};
return Some(ecx.create_err(errors::FormatRedundantArgs {
n: args_spans.len(),
span: MultiSpan::from(args_spans),
note: multispan,
sugg: errors::FormatRedundantArgsSugg { spans: suggestion_spans },
sugg,
}));
}