diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2022-08-26 11:09:06 +0200 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2022-08-30 09:48:03 +0200 |
| commit | 9dc0643744c87e5470e29718b86f54430cc7ba04 (patch) | |
| tree | 074a997f2af9abf81e78f8a2832ea5afe403ab3a /compiler/rustc_macros/src | |
| parent | 6e8dad5c073555dcbea9a276f76db47e3d7cc693 (diff) | |
| download | rust-9dc0643744c87e5470e29718b86f54430cc7ba04.tar.gz rust-9dc0643744c87e5470e29718b86f54430cc7ba04.zip | |
SessionSubdiagnostic: make `#[applicability]` optional
Diffstat (limited to 'compiler/rustc_macros/src')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/subdiagnostic.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 0db15f0feea..f66565af4c1 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -469,14 +469,10 @@ impl<'a> SessionSubdiagnosticDeriveBuilder<'a> { }; let span_field = self.span_field.as_ref().map(|(span, _)| span); - let applicability = match self.applicability.clone() { - Some((applicability, _)) => Some(applicability), - None if is_suggestion => { - span_err(self.span, "suggestion without `applicability`").emit(); - Some(quote! { rustc_errors::Applicability::Unspecified }) - } - None => None, - }; + let applicability = self.applicability.take().map_or_else( + || quote! { rustc_errors::Applicability::Unspecified }, + |(applicability, _)| applicability, + ); let diag = &self.diag; let name = format_ident!("{}{}", if span_field.is_some() { "span_" } else { "" }, kind); |
