diff --git a/crates/oxc_parser/src/cursor.rs b/crates/oxc_parser/src/cursor.rs index 57dd9f0fbda3e..f49a64b5510a0 100644 --- a/crates/oxc_parser/src/cursor.rs +++ b/crates/oxc_parser/src/cursor.rs @@ -136,6 +136,7 @@ impl<'a> ParserImpl<'a> { /// Advance and return true if we are at `Kind`, return false otherwise #[inline] + #[must_use = "Use `bump` instead of `eat` if you are ignoring the return value"] pub(crate) fn eat(&mut self, kind: Kind) -> bool { if self.at(kind) { self.advance(kind); @@ -144,7 +145,7 @@ impl<'a> ParserImpl<'a> { false } - /// Advance and return true if we are at `Kind` + /// Advance if we are at `Kind` #[inline] pub(crate) fn bump(&mut self, kind: Kind) { if self.at(kind) { diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 7c8a86e2c451f..b8c9fdc4d4553 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -97,7 +97,7 @@ impl<'a> ParserImpl<'a> { && self.at(Kind::Bang) && !self.cur_token().is_on_new_line() { - self.eat(Kind::Bang); + self.bump(Kind::Bang); definite = true; } let optional = self.eat(Kind::Question); // not allowed, but checked in checker/typescript.rs diff --git a/crates/oxc_parser/src/js/object.rs b/crates/oxc_parser/src/js/object.rs index 25c955ac776bc..678bce32bf6c6 100644 --- a/crates/oxc_parser/src/js/object.rs +++ b/crates/oxc_parser/src/js/object.rs @@ -21,7 +21,7 @@ impl<'a> ParserImpl<'a> { Self::parse_object_expression_property, ) }); - self.eat(Kind::Comma); // Trailing Comma + self.bump(Kind::Comma); // Trailing Comma self.expect(Kind::RCurly); self.ast.alloc_object_expression(self.end_span(span), object_expression_properties) }