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.
This commit is contained in:
Nicholas Nethercote 2023-12-14 14:13:35 +11:00
parent 2c2c7f13a6
commit 9a78412511
12 changed files with 64 additions and 45 deletions

View file

@ -277,8 +277,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
// "secondary" errors if they occurred.
let secondary_errors = mem::take(&mut self.secondary_errors);
if self.error_emitted.is_none() {
for mut error in secondary_errors {
self.tcx.sess.diagnostic().emit_diagnostic(&mut error);
for error in secondary_errors {
self.tcx.sess.diagnostic().emit_diagnostic(error);
}
} else {
assert!(self.tcx.sess.has_errors().is_some());