From 7045cad3307327adef735d4eecbbce25002b1ba2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 14 Dec 2023 14:13:35 +1100 Subject: [PATCH] Split `Handler::emit_diagnostic` in two. Currently, `emit_diagnostic` takes `&mut self`. This commit changes it so `emit_diagnostic` takes `self` and the new `emit_diagnostic_without_consuming` function takes `&mut self`. I find the distinction useful. The former case is much more common, and avoids a bunch of `mut` and `&mut` occurrences. We can also restrict the latter with `pub(crate)` which is nice. --- src/parse/session.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/parse/session.rs b/src/parse/session.rs index 0573df9de2f..06f9c4c6243 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -284,10 +284,8 @@ pub(crate) fn get_original_snippet(&self, file_name: &FileName) -> Option) { - for mut diagnostic in diagnostics { - self.parse_sess - .span_diagnostic - .emit_diagnostic(&mut diagnostic); + for diagnostic in diagnostics { + self.parse_sess.span_diagnostic.emit_diagnostic(diagnostic); } }