From 2b4c52758c503b08d3299ad2d1ee369ad5f597f1 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 28 Sep 2023 07:13:45 +0200 Subject: refactor: remove DefaultEmitter::push_error helper fn --- src/default_emitter.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/default_emitter.rs b/src/default_emitter.rs index 16766c8..a4c5a63 100644 --- a/src/default_emitter.rs +++ b/src/default_emitter.rs @@ -43,7 +43,7 @@ impl Iterator for DefaultEmitter { impl Emitter for DefaultEmitter { fn report_error(&mut self, error: Error, span: Range) { - self.push_error(error, span); + self.emitted_tokens.push_front(Token::Error { error, span }); } fn emit_eof(&mut self) { @@ -85,7 +85,7 @@ impl Emitter for DefaultEmitter { Token::EndTag(tag) => { if !self.seen_attributes.is_empty() { let span = self.attr_in_end_tag_span.take().unwrap(); - self.push_error(Error::EndTagWithAttributes, span); + self.report_error(Error::EndTagWithAttributes, span); } self.seen_attributes.clear(); tag.span.end = offset; @@ -334,13 +334,13 @@ impl DefaultEmitter { vacant.insert(map_val); } Entry::Occupied(_) => { - self.push_error(Error::DuplicateAttribute, map_val.name_span); + self.report_error(Error::DuplicateAttribute, map_val.name_span); } }, Some(Token::EndTag(_)) => { self.attr_in_end_tag_span = Some(map_val.name_span.clone()); if !self.seen_attributes.insert(name) { - self.push_error(Error::DuplicateAttribute, map_val.name_span); + self.report_error(Error::DuplicateAttribute, map_val.name_span); } } _ => { @@ -358,12 +358,6 @@ impl DefaultEmitter { let s = mem::take(&mut self.current_characters); self.emit_token(Token::String(s)); } - - fn push_error(&mut self, error: Error, span: Range) { - // bypass character flushing in self.emit_token: we don't need the error location to be - // that exact - self.emitted_tokens.push_front(Token::Error { error, span }); - } } /// The majority of our testing of the [`DefaultEmitter`] is done against the -- cgit v1.2.3