Make Emitter::emit_diagnostic consuming.
All the other `emit`/`emit_diagnostic` methods were recently made consuming (e.g. #119606), but this one wasn't. But it makes sense to. Much of this is straightforward, and lots of `clone` calls are avoided. There are a couple of tricky bits. - `Emitter::primary_span_formatted` no longer takes a `Diagnostic` and returns a pair. Instead it takes the two fields from `Diagnostic` that it used (`span` and `suggestions`) as `&mut`, and modifies them. This is necessary to avoid the cloning of `diag.children` in two emitters. - `from_errors_diagnostic` is rearranged so various uses of `diag` occur before the consuming `emit_diagnostic` call.
This commit is contained in:
parent
4e3eed4892
commit
d9508a1fd2
7 changed files with 84 additions and 75 deletions
|
|
@ -156,7 +156,7 @@ impl Translate for BufferEmitter {
|
|||
}
|
||||
|
||||
impl Emitter for BufferEmitter {
|
||||
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, diag: Diagnostic) {
|
||||
let mut buffer = self.buffer.borrow_mut();
|
||||
|
||||
let fluent_args = to_fluent_args(diag.args());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue