1
Fork 0

Use diagnostic impls and add suggestions in redundant format!() args

This commit is contained in:
francorbacho 2023-10-04 15:47:53 +02:00
parent 4cc2d0bd65
commit 04fc051a34
5 changed files with 110 additions and 79 deletions

View file

@ -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 {