diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2022-09-10 14:28:12 +0200 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2022-09-22 17:25:50 +0200 |
| commit | 2e72387fd03082cd067a4a56acf4b231b543c7fd (patch) | |
| tree | 6eb734ac33abe25b32576d348c00a6d726e69f57 /compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | |
| parent | adcc55d622e92b6067deb76c6c1159802ed96fae (diff) | |
| download | rust-2e72387fd03082cd067a4a56acf4b231b543c7fd.tar.gz rust-2e72387fd03082cd067a4a56acf4b231b543c7fd.zip | |
Ensure code= in #[suggestion(...)] is only set once
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs index 2bff12b0059..11459e18190 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs @@ -476,7 +476,7 @@ impl DiagnosticDeriveBuilder { match nested_name { "code" => { let formatted_str = self.build_format(&s.value(), s.span()); - code = Some(formatted_str); + code.set_once((formatted_str, span)); } "applicability" => { applicability = match applicability { @@ -524,7 +524,7 @@ impl DiagnosticDeriveBuilder { let msg = msg.unwrap_or_else(|| parse_quote! { _subdiag::suggestion }); let msg = quote! { rustc_errors::fluent::#msg }; - let code = code.unwrap_or_else(|| quote! { String::new() }); + let code = code.value().unwrap_or_else(|| quote! { String::new() }); Ok(quote! { #diag.#method(#span_field, #msg, #code, #applicability); }) } |
