diff options
| author | David Wood <david.wood@huawei.com> | 2022-07-11 17:15:31 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-07-15 16:13:49 +0100 |
| commit | 88c11c5bfffea445c6cc49b62da17f172eb8f055 (patch) | |
| tree | 1b5cbd5bd5b9a384bbd6ed7830777f42ba39c309 /compiler/rustc_macros/src/diagnostics/utils.rs | |
| parent | c3fdf748856fa220dc251647808db8535ac0bba2 (diff) | |
| download | rust-88c11c5bfffea445c6cc49b62da17f172eb8f055.tar.gz rust-88c11c5bfffea445c6cc49b62da17f172eb8f055.zip | |
macros: support `MultiSpan` in diag derives
Add support for `MultiSpan` with any of the attributes that work on a `Span` - requires that diagnostic logic generated for these attributes are emitted in the by-move block rather than the by-ref block that they would normally have been generated in. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/utils.rs')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/utils.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index 8977db4606c..002abb152f7 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -85,7 +85,13 @@ pub(crate) fn report_error_if_not_applied_to_span( attr: &Attribute, info: &FieldInfo<'_>, ) -> Result<(), DiagnosticDeriveError> { - report_error_if_not_applied_to_ty(attr, info, &["rustc_span", "Span"], "`Span`") + if !type_matches_path(&info.ty, &["rustc_span", "Span"]) + && !type_matches_path(&info.ty, &["rustc_errors", "MultiSpan"]) + { + report_type_error(attr, "`Span` or `MultiSpan`")?; + } + + Ok(()) } /// Inner type of a field and type of wrapper. |
