diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 04fdada80249..dcd0116d804d 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -220,7 +220,7 @@ fn identify_kind( } /// Generates the code for a field with no attributes. - fn generate_field_arg(&mut self, binding_info: &BindingInfo<'_>) -> (TokenStream, TokenStream) { + fn generate_field_arg(&mut self, binding_info: &BindingInfo<'_>) -> TokenStream { let diag = &self.parent.diag; let field = binding_info.ast(); @@ -230,16 +230,12 @@ fn generate_field_arg(&mut self, binding_info: &BindingInfo<'_>) -> (TokenStream let ident = field.ident.as_ref().unwrap(); let ident = format_ident!("{}", ident); // strip `r#` prefix, if present - let args = quote! { + quote! { #diag.arg( stringify!(#ident), #field_binding ); - }; - let remove_args = quote! { - #diag.remove_arg(stringify!(#ident)); - }; - (args, remove_args) + } } /// Generates the necessary code for all attributes on a field. @@ -610,7 +606,7 @@ pub(crate) fn into_tokens(&mut self) -> Result Result to be used. // - Restore the arguments for allowing main and subdiagnostic share the same fields. Ok(quote! { #init @@ -634,7 +629,6 @@ pub(crate) fn into_tokens(&mut self) -> Result