diff options
| author | jyn <github@jyn.dev> | 2023-12-24 18:34:31 -0500 |
|---|---|---|
| committer | jyn <github@jyn.dev> | 2024-10-27 21:23:28 -0400 |
| commit | 3141a65d253829eadcb525abb9f418fd752c5718 (patch) | |
| tree | 1abe263dc96ce01b8286e7566a3630e533af65cf /compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | |
| parent | d792e1f50af4c7006c351ff1eed8c32eee10d3e8 (diff) | |
| download | rust-3141a65d253829eadcb525abb9f418fd752c5718.tar.gz rust-3141a65d253829eadcb525abb9f418fd752c5718.zip | |
give a better error for tuple structs in `derive(Diagnostic)`
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs index 72f1e599247..1055f27c1e4 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs @@ -253,7 +253,10 @@ impl DiagnosticDeriveVariantBuilder { let mut field_binding = binding_info.binding.clone(); field_binding.set_span(field.ty.span()); - let ident = field.ident.as_ref().unwrap(); + let Some(ident) = field.ident.as_ref() else { + span_err(field.span().unwrap(), "tuple structs are not supported").emit(); + return TokenStream::new(); + }; let ident = format_ident!("{}", ident); // strip `r#` prefix, if present quote! { |
