Skip to content

Commit 36902fb

Browse files
committed
Fix subdiagnostic-only enum variants not generating code
1 parent eee14e9 commit 36902fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_macros/src/diagnostics/subdiagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,11 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
510510
.map(|binding| self.generate_field_attr_code(binding, kind_stats))
511511
.collect();
512512

513-
if kind_slugs.is_empty() {
513+
if kind_slugs.is_empty() && !self.has_subdiagnostic {
514514
if self.is_enum {
515515
// It's okay for a variant to not be a subdiagnostic at all..
516516
return Ok(quote! {});
517-
} else if !self.has_subdiagnostic {
517+
} else {
518518
// ..but structs should always be _something_.
519519
throw_span_err!(
520520
self.variant.ast().ident.span().unwrap(),

0 commit comments

Comments
 (0)