about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-12-14 14:13:35 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-12-15 10:13:12 +1100
commit7045cad3307327adef735d4eecbbce25002b1ba2 (patch)
tree021bd78b04888cc2032a2f2fec25c5cd550b3c53
parent948c9047d56e95a72c50f623b561b71b0d0ee9ae (diff)
downloadrust-7045cad3307327adef735d4eecbbce25002b1ba2.tar.gz
rust-7045cad3307327adef735d4eecbbce25002b1ba2.zip
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.
-rw-r--r--src/parse/session.rs6
1 files 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 @@ impl ParseSess {
 // Methods that should be restricted within the parse module.
 impl ParseSess {
     pub(super) fn emit_diagnostics(&self, diagnostics: Vec<Diagnostic>) {
-        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);
         }
     }