From c16089fd40168d157cd3ca064948534f777e33bd Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 17 Mar 2026 15:08:13 -0600 Subject: [PATCH] codex: fix PR #14987 clippy regression --- codex-rs/tui/src/bottom_pane/prompt_args.rs | 10 ++++++++++ codex-rs/tui_app_server/src/bottom_pane/prompt_args.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/codex-rs/tui/src/bottom_pane/prompt_args.rs b/codex-rs/tui/src/bottom_pane/prompt_args.rs index 46cec29242..a0953aa36f 100644 --- a/codex-rs/tui/src/bottom_pane/prompt_args.rs +++ b/codex-rs/tui/src/bottom_pane/prompt_args.rs @@ -1,5 +1,8 @@ +#[cfg(test)] use codex_protocol::user_input::ByteRange; +#[cfg(test)] use codex_protocol::user_input::TextElement; +#[cfg(test)] use shlex::Shlex; /// Parse a first-line slash command of the form `/name `. @@ -28,6 +31,7 @@ pub fn parse_slash_name(line: &str) -> Option<(&str, &str, usize)> { Some((name, rest, rest_offset)) } +#[cfg(test)] #[derive(Debug, Clone, PartialEq)] pub struct PromptArg { pub text: String, @@ -37,10 +41,12 @@ pub struct PromptArg { /// Parse positional arguments using shlex semantics (supports quoted tokens). /// /// `text_elements` must be relative to `rest`. +#[cfg(test)] pub fn parse_positional_args(rest: &str, text_elements: &[TextElement]) -> Vec { parse_tokens_with_elements(rest, text_elements) } +#[cfg(test)] fn parse_tokens_with_elements(rest: &str, text_elements: &[TextElement]) -> Vec { let mut elements = text_elements.to_vec(); elements.sort_by_key(|elem| elem.byte_range.start); @@ -50,6 +56,7 @@ fn parse_tokens_with_elements(rest: &str, text_elements: &[TextElement]) -> Vec< .collect() } +#[cfg(test)] #[derive(Debug, Clone)] struct ElementReplacement { sentinel: String, @@ -57,6 +64,7 @@ struct ElementReplacement { placeholder: Option, } +#[cfg(test)] fn replace_text_elements_with_sentinels( rest: &str, elements: &[TextElement], @@ -86,6 +94,7 @@ fn replace_text_elements_with_sentinels( (out, replacements) } +#[cfg(test)] fn apply_replacements_to_token(token: String, replacements: &[ElementReplacement]) -> PromptArg { if replacements.is_empty() { return PromptArg { @@ -123,6 +132,7 @@ fn apply_replacements_to_token(token: String, replacements: &[ElementReplacement } } +#[cfg(test)] fn next_replacement<'a>( token: &str, cursor: usize, diff --git a/codex-rs/tui_app_server/src/bottom_pane/prompt_args.rs b/codex-rs/tui_app_server/src/bottom_pane/prompt_args.rs index 46cec29242..a0953aa36f 100644 --- a/codex-rs/tui_app_server/src/bottom_pane/prompt_args.rs +++ b/codex-rs/tui_app_server/src/bottom_pane/prompt_args.rs @@ -1,5 +1,8 @@ +#[cfg(test)] use codex_protocol::user_input::ByteRange; +#[cfg(test)] use codex_protocol::user_input::TextElement; +#[cfg(test)] use shlex::Shlex; /// Parse a first-line slash command of the form `/name `. @@ -28,6 +31,7 @@ pub fn parse_slash_name(line: &str) -> Option<(&str, &str, usize)> { Some((name, rest, rest_offset)) } +#[cfg(test)] #[derive(Debug, Clone, PartialEq)] pub struct PromptArg { pub text: String, @@ -37,10 +41,12 @@ pub struct PromptArg { /// Parse positional arguments using shlex semantics (supports quoted tokens). /// /// `text_elements` must be relative to `rest`. +#[cfg(test)] pub fn parse_positional_args(rest: &str, text_elements: &[TextElement]) -> Vec { parse_tokens_with_elements(rest, text_elements) } +#[cfg(test)] fn parse_tokens_with_elements(rest: &str, text_elements: &[TextElement]) -> Vec { let mut elements = text_elements.to_vec(); elements.sort_by_key(|elem| elem.byte_range.start); @@ -50,6 +56,7 @@ fn parse_tokens_with_elements(rest: &str, text_elements: &[TextElement]) -> Vec< .collect() } +#[cfg(test)] #[derive(Debug, Clone)] struct ElementReplacement { sentinel: String, @@ -57,6 +64,7 @@ struct ElementReplacement { placeholder: Option, } +#[cfg(test)] fn replace_text_elements_with_sentinels( rest: &str, elements: &[TextElement], @@ -86,6 +94,7 @@ fn replace_text_elements_with_sentinels( (out, replacements) } +#[cfg(test)] fn apply_replacements_to_token(token: String, replacements: &[ElementReplacement]) -> PromptArg { if replacements.is_empty() { return PromptArg { @@ -123,6 +132,7 @@ fn apply_replacements_to_token(token: String, replacements: &[ElementReplacement } } +#[cfg(test)] fn next_replacement<'a>( token: &str, cursor: usize,