Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 7733a7f

Browse files
authored
Add MapExtra::emit(&mut self, E::Error) method (#880)
* Add `MapExtra::emit(&mut self, E::Error)` method * Directly push the error, removing one `Vec` * chore: fix fmt
1 parent bff8734 commit 7733a7f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/input.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ pub struct MapExtra<'src, 'b, I: Input<'src>, E: ParserExtra<'src, I>> {
18401840
cache: &'b mut I::Cache,
18411841
state: &'b mut E::State,
18421842
ctx: &'b E::Context,
1843+
emitted: &'b mut Errors<I::Cursor, E::Error>,
18431844
}
18441845

18451846
impl<'src, 'b, I: Input<'src>, E: ParserExtra<'src, I>> MapExtra<'src, 'b, I, E> {
@@ -1854,6 +1855,7 @@ impl<'src, 'b, I: Input<'src>, E: ParserExtra<'src, I>> MapExtra<'src, 'b, I, E>
18541855
cache: inp.cache,
18551856
ctx: inp.ctx,
18561857
state: inp.state,
1858+
emitted: &mut inp.errors,
18571859
}
18581860
}
18591861

@@ -1887,4 +1889,11 @@ impl<'src, 'b, I: Input<'src>, E: ParserExtra<'src, I>> MapExtra<'src, 'b, I, E>
18871889
pub fn ctx(&self) -> &E::Context {
18881890
self.ctx
18891891
}
1892+
1893+
/// Emits an non-fatal error.
1894+
pub fn emit(&mut self, err: E::Error) {
1895+
self.emitted
1896+
.secondary
1897+
.push(Located::at(self.before.clone(), err));
1898+
}
18901899
}

0 commit comments

Comments
 (0)