diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-03 16:00:29 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-08 15:43:07 +1100 |
| commit | 589591efde6c54baa8b7932ec3be6f45dc9d781f (patch) | |
| tree | 111b41a6211a9101546d182d294f552734c092c6 /compiler/rustc_builtin_macros/src/errors.rs | |
| parent | b1b9278851a9512a0c934c12f9c1800169c336f7 (diff) | |
| download | rust-589591efde6c54baa8b7932ec3be6f45dc9d781f.tar.gz rust-589591efde6c54baa8b7932ec3be6f45dc9d781f.zip | |
Use chaining in `DiagnosticBuilder` construction.
To avoid the use of a mutable local variable, and because it reads more nicely.
Diffstat (limited to 'compiler/rustc_builtin_macros/src/errors.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/errors.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index f9ddffcc155..13e5a40ca9e 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -803,24 +803,23 @@ pub(crate) struct AsmClobberNoReg { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg { fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - let mut diag = DiagnosticBuilder::new( - dcx, - level, - crate::fluent_generated::builtin_macros_asm_clobber_no_reg, - ); - diag.span(self.spans.clone()); // eager translation as `span_labels` takes `AsRef<str>` let lbl1 = dcx.eagerly_translate_to_string( crate::fluent_generated::builtin_macros_asm_clobber_abi, [].into_iter(), ); - diag.span_labels(self.clobbers, &lbl1); let lbl2 = dcx.eagerly_translate_to_string( crate::fluent_generated::builtin_macros_asm_clobber_outputs, [].into_iter(), ); - diag.span_labels(self.spans, &lbl2); - diag + DiagnosticBuilder::new( + dcx, + level, + crate::fluent_generated::builtin_macros_asm_clobber_no_reg, + ) + .span_mv(self.spans.clone()) + .span_labels_mv(self.clobbers, &lbl1) + .span_labels_mv(self.spans, &lbl2) } } |
