From afa80f3e5efd1c6af91f952ce9590cf70269a7a5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 24 Dec 2023 09:08:41 +1100 Subject: [PATCH 1/2] Rename some `Diagnostic` setters. `Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods. --- src/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 4375fa67b8..d9b4eb2f0a 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -459,7 +459,7 @@ pub fn report_msg<'tcx>( DiagLevel::Note => Level::Note, }; let mut err = DiagnosticBuilder::<()>::new(sess.dcx(), level, title); - err.set_span(span); + err.span(span); // Show main message. if span != DUMMY_SP { From 9e19369e1b19f2f5e06e236cc8c4375080918ba8 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 4 Jan 2024 11:44:37 +1100 Subject: [PATCH 2/2] Remove `is_lint` field from `Level::Error`. Because it's redundant w.r.t. `Diagnostic::is_lint`, which is present for every diagnostic level. `struct_lint_level_impl` was the only place that set the `Error` field to `true`, and it's also the only place that calls `Diagnostic::is_lint()` to set the `is_lint` field. --- src/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index d9b4eb2f0a..d3d4490f30 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -454,7 +454,7 @@ pub fn report_msg<'tcx>( let span = stacktrace.first().map_or(DUMMY_SP, |fi| fi.span); let sess = machine.tcx.sess; let level = match diag_level { - DiagLevel::Error => Level::Error { lint: false }, + DiagLevel::Error => Level::Error, DiagLevel::Warning => Level::Warning(None), DiagLevel::Note => Level::Note, };