Use diagnostic impls and add suggestions in redundant format!() args
This commit is contained in:
parent
4cc2d0bd65
commit
04fc051a34
5 changed files with 110 additions and 79 deletions
|
@ -646,6 +646,27 @@ pub(crate) struct FormatPositionalMismatch {
|
|||
pub(crate) highlight: SingleLabelManySpans,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_format_redundant_args)]
|
||||
pub(crate) struct FormatRedundantArgs {
|
||||
#[primary_span]
|
||||
pub(crate) fmt_span: Span,
|
||||
pub(crate) n: usize,
|
||||
|
||||
#[note]
|
||||
pub(crate) note: MultiSpan,
|
||||
|
||||
#[subdiagnostic]
|
||||
pub(crate) sugg: FormatRedundantArgsSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(builtin_macros_suggestion, applicability = "machine-applicable")]
|
||||
pub(crate) struct FormatRedundantArgsSugg {
|
||||
#[suggestion_part(code = "")]
|
||||
pub(crate) spans: Vec<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_test_case_non_item)]
|
||||
pub(crate) struct TestCaseNonItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue