about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-03 17:03:10 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-08 15:45:29 +1100
commitbd4e623485f383b478fae662a767a3129bb4b989 (patch)
treefe4207cae336d51d0c29fd430b1d402d1de8339e /compiler/rustc_parse/src/parser/diagnostics.rs
parent589591efde6c54baa8b7932ec3be6f45dc9d781f (diff)
downloadrust-bd4e623485f383b478fae662a767a3129bb4b989.tar.gz
rust-bd4e623485f383b478fae662a767a3129bb4b989.zip
Use chaining for `DiagnosticBuilder` construction and `emit`.
To avoid the use of a mutable local variable, and because it reads more
nicely.
Diffstat (limited to 'compiler/rustc_parse/src/parser/diagnostics.rs')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 02eab2bac58..66d80fa3c52 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -2848,15 +2848,16 @@ impl<'a> Parser<'a> {
         let label = self.eat_label().expect("just checked if a label exists");
         self.bump(); // eat `:`
         let span = label.ident.span.to(self.prev_token.span);
-        let mut err = self.dcx().struct_span_err(span, "block label not supported here");
-        err.span_label(span, "not supported here");
-        err.tool_only_span_suggestion(
-            label.ident.span.until(self.token.span),
-            "remove this block label",
-            "",
-            Applicability::MachineApplicable,
-        );
-        err.emit();
+        self.dcx()
+            .struct_span_err(span, "block label not supported here")
+            .span_label_mv(span, "not supported here")
+            .tool_only_span_suggestion_mv(
+                label.ident.span.until(self.token.span),
+                "remove this block label",
+                "",
+                Applicability::MachineApplicable,
+            )
+            .emit();
         true
     }