From cf6170200cfb83c892d5cd8c04376d16b8589032 Mon Sep 17 00:00:00 2001 From: Daniel Rainer Date: Sat, 11 Apr 2026 02:37:35 +0200 Subject: [PATCH] refactor: move const to `fish_widestring` Another step to eliminate dependency cycles between `src/expand.rs` and `src/common.rs`. Part of #12625 --- crates/widestring/src/lib.rs | 3 +++ src/common.rs | 7 +++---- src/expand.rs | 3 --- src/highlight/highlight.rs | 8 +++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/widestring/src/lib.rs b/crates/widestring/src/lib.rs index 68cb7ee0a..29698fb20 100644 --- a/crates/widestring/src/lib.rs +++ b/crates/widestring/src/lib.rs @@ -103,6 +103,9 @@ pub mod prelude { "Characters used in expansions must stay within private use area" ); +/// The string represented by PROCESS_EXPAND_SELF +pub const PROCESS_EXPAND_SELF_STR: &wstr = L!("%self"); + /// Return true if the character is in a range reserved for fish's private use. /// /// NOTE: This is used when tokenizing the input. It is also used when reading input, before diff --git a/src/common.rs b/src/common.rs index 3a2db9039..c808d29de 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,6 @@ //! Prototypes for various functions, mostly string utilities, that are used by most parts of fish. use crate::{ - expand::PROCESS_EXPAND_SELF_STR, global_safety::{AtomicRef, RelaxedAtomicBool}, prelude::*, terminal::Outputter, @@ -12,9 +11,9 @@ use fish_feature_flags::{FeatureFlag, feature_test}; use fish_widestring::{ ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE, ASCII_MAX, BRACE_BEGIN, BRACE_END, BRACE_SEP, - BRACE_SPACE, BYTE_MAX, HOME_DIRECTORY, INTERNAL_SEPARATOR, PROCESS_EXPAND_SELF, UCS2_MAX, - VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE, bytes2wcstring, decode_byte_from_char, - fish_reserved_codepoint, subslice_position, wcs2bytes, + BRACE_SPACE, BYTE_MAX, HOME_DIRECTORY, INTERNAL_SEPARATOR, PROCESS_EXPAND_SELF, + PROCESS_EXPAND_SELF_STR, UCS2_MAX, VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE, bytes2wcstring, + decode_byte_from_char, fish_reserved_codepoint, subslice_position, wcs2bytes, }; use nix::sys::termios::Termios; use std::{ diff --git a/src/expand.rs b/src/expand.rs index 4ba48744e..75a66d4ac 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -106,9 +106,6 @@ fn eq(&self, other: &ExpandResultCode) -> bool { } } -/// The string represented by PROCESS_EXPAND_SELF -pub const PROCESS_EXPAND_SELF_STR: &wstr = L!("%self"); - /// Perform various forms of expansion on in, such as tilde expansion (\~USER becomes the users home /// directory), variable expansion (\$VAR_NAME becomes the value of the environment variable /// VAR_NAME), cmdsubst expansion and wildcard expansion. The results are inserted into the list diff --git a/src/highlight/highlight.rs b/src/highlight/highlight.rs index 32b268ff6..af071c3f0 100644 --- a/src/highlight/highlight.rs +++ b/src/highlight/highlight.rs @@ -9,10 +9,7 @@ common::{valid_var_name, valid_var_name_char}, complete::complete_wrap_map, env::{EnvVar, Environment}, - expand::{ - ExpandFlags, ExpandResultCode, PROCESS_EXPAND_SELF_STR, expand_one, - expand_to_command_and_args, - }, + expand::{ExpandFlags, ExpandResultCode, expand_one, expand_to_command_and_args}, function, highlight::file_tester::FileTester, history::all_paths_are_valid, @@ -33,7 +30,8 @@ use fish_feature_flags::{FeatureFlag, feature_test}; use fish_wcstringutil::string_prefixes_string; use fish_widestring::{ - ASCII_MAX, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, L, WExt as _, WString, wstr, + ASCII_MAX, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, L, PROCESS_EXPAND_SELF_STR, WExt as _, + WString, wstr, }; use std::collections::{HashMap, hash_map::Entry};