Skip to content

Commit

Permalink
refactor(parser): remove dead code warning when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 16, 2024
1 parent bb95306 commit ab2f19f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<'a> Lexer<'a> {
source_text: &'a str,
source_type: SourceType,
) -> Self {
let unique = UniquePromise::new_for_tests();
let unique = UniquePromise::new_for_benchmarks();
Self::new(allocator, source_text, source_type, unique)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod parser_parse {
///
/// `UniquePromise` is a zero-sized type and has no runtime cost. It's purely for the type-checker.
///
/// `UniquePromise::new_for_tests` is a backdoor for unit tests and benchmarks, so they can create a
/// `UniquePromise::new_for_benchmarks` is a backdoor for benchmarks, so they can create a
/// `ParserImpl` or `Lexer`, and manipulate it directly, for testing/benchmarking purposes.
pub(crate) struct UniquePromise {
_dummy: (),
Expand All @@ -191,8 +191,8 @@ mod parser_parse {
/// Backdoor for tests/benchmarks to create a `UniquePromise` (see above).
/// This function must NOT be exposed outside of tests and benchmarks,
/// as it allows circumventing safety invariants of the parser.
#[cfg(any(test, feature = "benchmarking"))]
pub fn new_for_tests() -> Self {
#[cfg(feature = "benchmarking")]
pub fn new_for_benchmarks() -> Self {
Self { _dummy: () }
}
}
Expand Down

0 comments on commit ab2f19f

Please sign in to comment.