macros: allow Vec fields in diagnostic derive

Diagnostics can have multiple primary spans, or have subdiagnostics
repeated at multiple locations, so support `Vec<..>` fields in the
diagnostic derive which become loops in the generated code.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-05-06 03:43:30 +01:00
parent 3dac70fcc0
commit 859079ff12
4 changed files with 93 additions and 39 deletions

View file

@ -474,3 +474,11 @@ struct Subdiagnostic {
#[subdiagnostic]
note: Note,
}
#[derive(SessionDiagnostic)]
#[error(code = "E0123", slug = "foo")]
struct VecField {
#[primary_span]
#[label]
spans: Vec<Span>,
}