diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2024-04-24 17:05:48 +0000 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2024-05-21 20:11:42 +0000 |
| commit | 36902fbcf6d3ae211141b393b93ceef632d0db57 (patch) | |
| tree | 2ef7b93ed14d768ee78e913d2a0fa766ea23cf04 | |
| parent | eee14e9adf525169f8ea6fdf2579f6abce7ab24c (diff) | |
Fix subdiagnostic-only enum variants not generating code
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/subdiagnostic.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 45236771bce..69014f39925 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -510,11 +510,11 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> { .map(|binding| self.generate_field_attr_code(binding, kind_stats)) .collect(); - if kind_slugs.is_empty() { + if kind_slugs.is_empty() && !self.has_subdiagnostic { if self.is_enum { // It's okay for a variant to not be a subdiagnostic at all.. return Ok(quote! {}); - } else if !self.has_subdiagnostic { + } else { // ..but structs should always be _something_. throw_span_err!( self.variant.ast().ident.span().unwrap(), |
