From e1f8ea41ad1493c2e5da399a62c2e9d8eef886a2 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 7 Jan 2025 06:58:25 +0000 Subject: [PATCH] fix(lexer): `Source` is not `Clone` (#8294) It's an invariant of `Source` that only a single instance of `Source` can exist at any time. `Source` was erroneously implementing `Clone`, which makes it trivial to break this invariant. `Clone` is unnecessary, so remove it. --- crates/oxc_parser/src/lexer/source.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/oxc_parser/src/lexer/source.rs b/crates/oxc_parser/src/lexer/source.rs index ce057077d84b6..615e77b478754 100644 --- a/crates/oxc_parser/src/lexer/source.rs +++ b/crates/oxc_parser/src/lexer/source.rs @@ -60,7 +60,6 @@ use super::search::SEARCH_BATCH_SIZE; /// are satisfied, to restore this invariant before passing control back to other code. /// It will often be preferable to instead use `Source::peek_byte`, followed by `Source::next_char`, /// which are safe methods, and compiler will often reduce to equally efficient code. -#[derive(Clone)] pub(super) struct Source<'a> { /// Pointer to start of source string. Never altered after initialization. start: *const u8,