From 589591efde6c54baa8b7932ec3be6f45dc9d781f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 3 Jan 2024 16:00:29 +1100 Subject: Use chaining in `DiagnosticBuilder` construction. To avoid the use of a mutable local variable, and because it reads more nicely. --- compiler/rustc_session/src/errors.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_session/src') 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)) } } -- cgit 1.4.1-3-g733a5