about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
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
commit9a7841251115c79fe7e1c12e2e5d637e19ad940a (patch)
tree073dcbd11af1207ae334d4dae991f2f4990d4c59 /compiler/rustc_parse/src
parent2c2c7f13a65f22969adf52a8040fb1bed842fb94 (diff)
downloadrust-9a7841251115c79fe7e1c12e2e5d637e19ad940a.tar.gz
rust-9a7841251115c79fe7e1c12e2e5d637e19ad940a.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.
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs
index 95352dbdc13..9887a85e6a4 100644
--- a/compiler/rustc_parse/src/lib.rs
+++ b/compiler/rustc_parse/src/lib.rs
@@ -51,8 +51,8 @@ macro_rules! panictry_buffer {
         match $e {
             Ok(e) => e,
             Err(errs) => {
-                for mut e in errs {
-                    $handler.emit_diagnostic(&mut e);
+                for e in errs {
+                    $handler.emit_diagnostic(e);
                 }
                 FatalError.raise()
             }
@@ -165,8 +165,8 @@ fn try_file_to_source_file(
 fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>) -> Lrc<SourceFile> {
     match try_file_to_source_file(sess, path, spanopt) {
         Ok(source_file) => source_file,
-        Err(mut d) => {
-            sess.span_diagnostic.emit_diagnostic(&mut d);
+        Err(d) => {
+            sess.span_diagnostic.emit_diagnostic(d);
             FatalError.raise();
         }
     }