about summary refs log tree commit diff
path: root/compiler/rustc_session/src/errors.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-03 16:00:29 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-08 15:43:07 +1100
commit589591efde6c54baa8b7932ec3be6f45dc9d781f (patch)
tree111b41a6211a9101546d182d294f552734c092c6 /compiler/rustc_session/src/errors.rs
parentb1b9278851a9512a0c934c12f9c1800169c336f7 (diff)
downloadrust-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_session/src/errors.rs')
-rw-r--r--compiler/rustc_session/src/errors.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs
index 758c3122404..8baa5d892a5 100644
--- a/compiler/rustc_session/src/errors.rs
+++ b/compiler/rustc_session/src/errors.rs
@@ -18,10 +18,9 @@ pub struct FeatureGateError {
 impl<'a> IntoDiagnostic<'a> for FeatureGateError {
     #[track_caller]
     fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a> {
-        let mut diag = DiagnosticBuilder::new(dcx, level, self.explain);
-        diag.span(self.span);
-        diag.code(error_code!(E0658));
-        diag
+        DiagnosticBuilder::new(dcx, level, self.explain)
+            .span_mv(self.span)
+            .code_mv(error_code!(E0658))
     }
 }