aboutsummaryrefslogtreecommitdiff
path: root/src/default_emitter.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-28 07:13:45 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 07:26:44 +0200
commit2b4c52758c503b08d3299ad2d1ee369ad5f597f1 (patch)
tree31890b673eca2966f5fe176b1dcd1214b5c9605b /src/default_emitter.rs
parent7493f019cd7991c336324711af2247eda3851ec5 (diff)
refactor: remove DefaultEmitter::push_error helper fn
Diffstat (limited to 'src/default_emitter.rs')
-rw-r--r--src/default_emitter.rs14
1 files changed, 4 insertions, 10 deletions
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<O> Iterator for DefaultEmitter<O> {
impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
fn report_error(&mut self, error: Error, span: Range<O>) {
- self.push_error(error, span);
+ self.emitted_tokens.push_front(Token::Error { error, span });
}
fn emit_eof(&mut self) {
@@ -85,7 +85,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
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<O> DefaultEmitter<O> {
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<O> DefaultEmitter<O> {
let s = mem::take(&mut self.current_characters);
self.emit_token(Token::String(s));
}
-
- fn push_error(&mut self, error: Error, span: Range<O>) {
- // 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