From ab2f19fbf314c0230200012d2a4294c3f3bfcd45 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 16 Sep 2024 14:48:34 +0100 Subject: [PATCH] refactor(parser): remove dead code warning when running tests --- crates/oxc_parser/src/lexer/mod.rs | 2 +- crates/oxc_parser/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index 307f7287c04aff..1bcbad2b721a59 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -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) } diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index e7a83562b1fd8d..be68a6fac2f00c 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -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: (), @@ -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: () } } }