macros: support adding warnings to diags

Both diagnostic and subdiagnostic derives were missing the ability to
add warnings to diagnostics - this is made more difficult by the `warn`
attribute already existing, so this name being unavailable for the
derives to use. `#[warn_]` is used instead, which requires
special-casing so that `{span_,}warn` is called instead of
`{span_,}warn_`.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-07-11 18:46:24 +01:00
parent 88c11c5bff
commit 81cf2294b4
8 changed files with 70 additions and 25 deletions

View file

@ -130,8 +130,9 @@ decl_derive!(
warning,
error,
lint,
note,
help,
note,
warn_,
// field attributes
skip_arg,
primary_span,
@ -148,8 +149,9 @@ decl_derive!(
warning,
error,
lint,
note,
help,
note,
warn_,
// field attributes
skip_arg,
primary_span,
@ -166,6 +168,7 @@ decl_derive!(
label,
help,
note,
warn_,
suggestion,
suggestion_short,
suggestion_hidden,