Skip to content

Commit

Permalink
refactor(parser): shorten UniquePromise code
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 16, 2024
1 parent ab2f19f commit b2fd87d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,20 @@ mod parser_parse {
///
/// `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: (),
}
pub(crate) struct UniquePromise(());

impl UniquePromise {
#[inline]
fn new() -> Self {
Self { _dummy: () }
Self(())
}

/// 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(feature = "benchmarking")]
pub fn new_for_benchmarks() -> Self {
Self { _dummy: () }
Self(())
}
}

Expand Down

0 comments on commit b2fd87d

Please sign in to comment.