rename: crate::wchar::prelude -> crate::prelude

Having the prelude in wchar is not great. The wchar module was empty
except for the prelude, and its prelude included things from wutil.

Having a top-level prelude module in the main crate resolves this. It
allows us to completely remove the wchar module, and a top-level prelude
module makes more sense conceptually. Putting non-wchar things into the
prelude also becomes more sensible, if we ever want to do that.

Closes #12182
This commit is contained in:
Daniel Rainer
2025-12-18 00:34:41 +01:00
committed by Johannes Altmanninger
parent 3b976a3364
commit b62a312cba
77 changed files with 113 additions and 115 deletions

View File

@@ -93,7 +93,7 @@ None of the Rust string types are nul-terminated. We're taking this opportunity
One may create a `&wstr` from a string literal using the `wchar::L!` macro:
```rust
use crate::wchar::prelude::*;
use crate::prelude::*;
// This imports wstr, the L! macro, WString, a ToWString trait that supplies .to_wstring() along with other things
fn get_shell_name() -> &'static wstr {

View File

@@ -3,7 +3,7 @@
sync::{Mutex, MutexGuard},
};
use crate::wchar::prelude::*;
use crate::prelude::*;
use once_cell::sync::Lazy;
use crate::parse_constants::SourceRange;
@@ -287,9 +287,9 @@ mod tests {
use super::{Abbreviation, Position, abbrs_get_set, abbrs_match, with_abbrs_mut};
use crate::editable_line::{Edit, apply_edit};
use crate::highlight::HighlightSpec;
use crate::prelude::*;
use crate::reader::reader_expand_abbreviation_at_cursor;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
#[serial]

View File

@@ -17,11 +17,11 @@
SourceRange, StatementDecoration, token_type_user_presentable_description,
};
use crate::parse_tree::ParseToken;
use crate::prelude::*;
use crate::tokenizer::{
TOK_ACCEPT_UNFINISHED, TOK_ARGUMENT_LIST, TOK_CONTINUE_AFTER_ERROR, TOK_SHOW_COMMENTS,
TokFlags, TokenType, Tokenizer, TokenizerError, variable_assignment_equals_pos,
};
use crate::wchar::prelude::*;
use macro_rules_attribute::derive;
use std::borrow::Cow;
use std::convert::AsMut;
@@ -2830,8 +2830,8 @@ mod tests {
use super::{Node, is_same_node};
use crate::ast;
use crate::parse_constants::ParseTreeFlags;
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
#[serial]
@@ -2898,7 +2898,7 @@ fn test_is_same_node() {
mod bench {
extern crate test;
use crate::ast;
use crate::wchar::prelude::*;
use crate::prelude::*;
use test::Bencher;
// Return a long string suitable for benchmarking.

View File

@@ -453,8 +453,8 @@ fn locate_asset(&self, cmd: &wstr, asset_dir: AssetDir) -> Option<AutoloadableFi
#[cfg(test)]
mod tests {
use super::{Autoload, AutoloadResult};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
#[serial]

View File

@@ -49,6 +49,7 @@
parse_util::parse_util_detect_errors_in_ast,
parser::{BlockType, CancelBehavior, Parser},
path::path_get_config,
prelude::*,
printf,
proc::{
Pid, get_login, is_interactive_session, mark_login, mark_no_exec, proc_init,
@@ -58,7 +59,6 @@
signal::{signal_clear_cancel, signal_unblock_all},
threads::{self},
topic_monitor,
wchar::prelude::*,
wutil::waccess,
};
use libc::STDIN_FILENO;

View File

@@ -12,6 +12,7 @@
parse_util_detect_errors, parse_util_get_offset_from_line, parse_util_job_extent,
parse_util_lineno, parse_util_process_extent, parse_util_token_extent,
};
use crate::prelude::*;
use crate::proc::is_interactive_session;
use crate::reader::{
commandline_get_state, commandline_set_buffer, commandline_set_search_field,
@@ -19,7 +20,6 @@
};
use crate::tokenizer::TOK_ACCEPT_UNFINISHED;
use crate::tokenizer::{TokenType, Tokenizer};
use crate::wchar::prelude::*;
use crate::wcstringutil::join_strings;
use std::ops::Range;

View File

@@ -24,11 +24,11 @@
use crate::operation_context::OperationContext;
use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange};
use crate::parse_util::{SPACES_PER_INDENT, apply_indents, parse_util_compute_indents};
use crate::prelude::*;
use crate::print_help::print_help;
use crate::threads;
use crate::tokenizer::{TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS, TokenType, Tokenizer};
use crate::topic_monitor::topic_monitor_init;
use crate::wchar::prelude::*;
use crate::wcstringutil::count_preceding_backslashes;
use crate::wgetopt::{ArgType, WGetopter, WOption, wopt};
use crate::wutil::fish_iswalnum;

View File

@@ -23,6 +23,7 @@
key::{Key, char_to_symbol},
nix::isatty,
panic::panic_handler,
prelude::*,
print_help::print_help,
proc::set_interactive_session,
reader::{
@@ -31,7 +32,6 @@
threads,
topic_monitor::topic_monitor_init,
tty_handoff::TtyHandoff,
wchar::prelude::*,
wgetopt::{ArgType, WGetopter, WOption, wopt},
};

View File

@@ -58,7 +58,7 @@ mod prelude {
flog::{flog, flogf},
io::{IoStreams, SeparationType},
parser::Parser,
wchar::prelude::*,
prelude::*,
wgetopt::{
ArgType::{self, *},
NON_OPTION_CHAR, WGetopter, WOption, wopt,

View File

@@ -997,7 +997,7 @@ pub fn path(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Bui
#[cfg(test)]
mod tests {
use super::find_extension;
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_find_extension() {

View File

@@ -2,15 +2,15 @@
use crate::builtins::shared::BuiltinResultExt;
use crate::io::IoChain;
use crate::io::{IoStreams, OutputStream, StringOutputStream};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[macro_export]
macro_rules! validate {
( [$($argv:expr),*], $expected_rc:expr, $expected_out:expr ) => {
{
use $crate::common::escape;
use $crate::wchar::prelude::*;
use $crate::prelude::*;
use $crate::builtins::string::test_helpers::string_test;
let (actual_out, actual_rc) = string_test(vec![$(L!($argv)),*]);
assert_eq!(escape(L!($expected_out)), escape(&actual_out));

View File

@@ -1,6 +1,6 @@
use std::cmp::Ordering;
use crate::wchar::prelude::*;
use crate::prelude::*;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Color24 {
@@ -322,7 +322,7 @@ fn term256_color_for_rgb(color: Color24) -> u8 {
#[cfg(test)]
mod tests {
use crate::color::{Color, Color24};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn parse() {

View File

@@ -9,9 +9,9 @@
use crate::global_safety::RelaxedAtomicBool;
use crate::key;
use crate::parse_util::parse_util_escape_string_with_quote;
use crate::prelude::*;
use crate::terminal::Output;
use crate::termsize::Termsize;
use crate::wchar::prelude::*;
use crate::wcstringutil::wcs2bytes_callback;
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::fish_iswalnum;
@@ -1807,7 +1807,7 @@ pub const fn assert_sync<T: Sync>() {}
/// # Examples
///
/// ```
/// use fish::wchar::prelude::*;
/// use fish::prelude::*;
/// use fish::assert_sorted_by_name;
///
/// const COLORS: &[(&wstr, u32)] = &[
@@ -1823,7 +1823,7 @@ pub const fn assert_sync<T: Sync>() {}
/// While this example would fail to compile:
///
/// ```compile_fail
/// use fish::wchar::prelude::*;
/// use fish::prelude::*;
/// use fish::assert_sorted_by_name;
///
/// const COLORS: &[(&wstr, u32)] = &[

View File

@@ -35,8 +35,8 @@
parser::{Block, Parser},
parser_keywords::parser_keywords_is_subcommand,
path::{path_get_path, path_try_get_path},
prelude::*,
tokenizer::{Tok, TokFlags, TokenType, Tokenizer, variable_assignment_equals_pos},
wchar::prelude::*,
wcstringutil::{
StringFuzzyMatch, string_fuzzy_match_string, string_prefixes_string,
string_prefixes_string_case_insensitive,
@@ -2637,9 +2637,9 @@ mod tests {
use crate::operation_context::{
EXPANSION_LIMIT_BACKGROUND, EXPANSION_LIMIT_DEFAULT, OperationContext, no_cancel,
};
use crate::prelude::*;
use crate::reader::completion_apply_to_command_line;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wcstringutil::join_strings;
use std::collections::HashMap;
use std::ffi::CString;

View File

@@ -1,7 +1,7 @@
use std::ops::Range;
use crate::highlight::HighlightSpec;
use crate::wchar::prelude::*;
use crate::prelude::*;
/// An edit action that can be undone.
#[derive(Clone, Eq, PartialEq)]
@@ -367,7 +367,7 @@ pub fn line_at_cursor(buffer: &wstr, cursor: usize) -> &wstr {
mod tests {
use crate::{
editable_line::{Edit, EditableLine},
wchar::prelude::*,
prelude::*,
};
#[test]

View File

@@ -19,10 +19,10 @@
path_emit_config_directory_messages, path_get_cache, path_get_config, path_get_data,
path_make_canonical, paths_are_same_file,
};
use crate::prelude::*;
use crate::proc::is_interactive_session;
use crate::termsize;
use crate::universal_notifier::default_notifier;
use crate::wchar::prelude::*;
use crate::wcstringutil::join_strings;
use crate::wutil::{fish_wcstol, wgetcwd, wgettext};
@@ -828,8 +828,8 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool
#[cfg(test)]
mod tests {
use super::{EnvMode, EnvStack, Environment};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
#[serial]

View File

@@ -10,9 +10,9 @@
use crate::kill::kill_entries;
use crate::nix::umask;
use crate::null_terminated_array::OwningNullTerminatedArray;
use crate::prelude::*;
use crate::reader::{commandline_get_state, reader_status_count};
use crate::threads::{is_forked_child, is_main_thread};
use crate::wchar::prelude::*;
use crate::wutil::fish_wcstol_radix;
use once_cell::sync::Lazy;
@@ -1158,7 +1158,7 @@ unsafe impl<T> Send for EnvMutex<T> {}
#[cfg(test)]
mod tests {
use super::colon_split;
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_colon_split() {

2
src/env/var.rs vendored
View File

@@ -297,8 +297,8 @@ pub fn is_read_only(name: &wstr) -> bool {
mod tests {
use super::{EnvMode, EnvVar, EnvVarFlags};
use crate::env::environment::{EnvStack, Environment};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use std::{
mem::MaybeUninit,
time::{SystemTime, UNIX_EPOCH},

View File

@@ -5,6 +5,7 @@
use crate::flog::flog;
use crate::input_common::{update_wait_on_escape_ms, update_wait_on_sequence_key_ms};
use crate::locale::{invalidate_numeric_locale, set_libc_locales};
use crate::prelude::*;
use crate::reader::{
reader_change_cursor_end_mode, reader_change_cursor_selection_mode, reader_change_history,
reader_schedule_prompt_repaint, reader_set_autosuggestion_enabled, reader_set_transient_prompt,
@@ -15,7 +16,6 @@
use crate::terminal::ColorSupport;
use crate::terminal::use_terminfo;
use crate::tty_handoff::xtversion;
use crate::wchar::prelude::*;
use crate::wcstringutil::string_prefixes_string;
use crate::wutil::fish_wcstoi;
use crate::{function, terminal};

View File

@@ -5,7 +5,7 @@
use crate::flog::{flog, flogf};
use crate::fs::{PotentialUpdate, lock_and_load, rewrite_via_temporary_file};
use crate::path::path_get_config;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wcstringutil::{LineIterator, join_strings};
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_file, file_id_for_path_narrow, wrealpath};
use fish_wchar::decode_byte_from_char;
@@ -815,8 +815,8 @@ mod tests {
use crate::common::wcs2osstring;
use crate::env::{EnvVar, EnvVarFlags, VarTable};
use crate::env_universal_common::{EnvUniversal, UvarFormat};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wutil::{INVALID_FILE_ID, file_id_for_path};
const UVARS_PER_THREAD: usize = 8;

View File

@@ -12,10 +12,10 @@
use crate::io::{IoChain, IoStreams};
use crate::job_group::MaybeJobId;
use crate::parser::{Block, Parser};
use crate::prelude::*;
use crate::proc::Pid;
use crate::reader::reader_update_termsize;
use crate::signal::{Signal, signal_check_cancel, signal_handle};
use crate::wchar::prelude::*;
pub enum EventType {
Any,

View File

@@ -33,6 +33,7 @@
use crate::nix::{getpid, isatty};
use crate::null_terminated_array::OwningNullTerminatedArray;
use crate::parser::{Block, BlockId, BlockType, EvalRes, Parser};
use crate::prelude::*;
use crate::proc::Pid;
use crate::proc::{
InternalProc, Job, JobGroupRef, ProcStatus, Process, ProcessType, hup_jobs,
@@ -43,7 +44,6 @@
use crate::threads::{ThreadPool, is_forked_child};
use crate::trace::trace_if_enabled_with_args;
use crate::tty_handoff::TtyHandoff;
use crate::wchar::prelude::*;
use crate::wutil::{fish_wcstol, perror};
use errno::{errno, set_errno};
use fish_wchar::ToWString;

View File

@@ -23,8 +23,8 @@
MaybeParentheses, parse_util_expand_variable_error, parse_util_locate_cmdsubst_range,
};
use crate::path::path_apply_working_directory;
use crate::prelude::*;
use crate::util::wcsfilecmp_glob;
use crate::wchar::prelude::*;
use crate::wcstringutil::{join_strings, trim};
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE, WildcardResult};
use crate::wildcard::{wildcard_expand_string, wildcard_has_internal};
@@ -1606,7 +1606,7 @@ mod tests {
use crate::{
expand::{ExpandFlags, expand_string},
operation_context::OperationContext,
wchar::prelude::*,
prelude::*,
};
use std::collections::HashSet;
use std::collections::hash_map::RandomState;

View File

@@ -1,7 +1,7 @@
use crate::common::wcs2zstring;
use crate::flog::flog;
use crate::prelude::*;
use crate::signal::signal_check_cancel;
use crate::wchar::prelude::*;
use crate::wutil::perror;
use cfg_if::cfg_if;
use libc::{EINTR, F_GETFD, F_GETFL, F_SETFD, F_SETFL, FD_CLOEXEC, O_NONBLOCK, c_int};

View File

@@ -1,5 +1,5 @@
use crate::common::wcs2bytes;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wildcard::wildcard_match;
use crate::wutil::write_to_fd;
use crate::{parse_util::parse_util_unescape_wildcards, wutil::wwrite_to_fd};
@@ -9,7 +9,7 @@
#[rustfmt::skip::macros(category)]
pub mod categories {
use super::wstr;
use crate::wchar::prelude::*;
use crate::prelude::*;
use std::sync::atomic::AtomicBool;
pub struct Category {

View File

@@ -3,7 +3,7 @@
fds::wopen_cloexec,
flog, flogf,
path::{DirRemoteness, path_remoteness},
wchar::prelude::*,
prelude::*,
wutil::{
FileId, INVALID_FILE_ID, file_id_for_file, file_id_for_path, wdirname, wrename, wunlink,
},

View File

@@ -12,7 +12,7 @@
use crate::parse_tree::NodeRef;
use crate::parser::Parser;
use crate::parser_keywords::parser_keywords_is_reserved;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wutil::dir_iter::DirIter;
use once_cell::sync::Lazy;
use std::collections::{HashMap, HashSet};

View File

@@ -1,6 +1,6 @@
//! Flags to enable upcoming features
use crate::wchar::prelude::*;
use crate::prelude::*;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
@@ -288,7 +288,7 @@ pub fn scoped_test(flag: FeatureFlag, value: bool, test_fn: impl FnOnce()) {
#[cfg(test)]
mod tests {
use super::{FeatureFlag, Features, METADATA, scoped_test, set, test};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_feature_flags() {

View File

@@ -421,8 +421,8 @@ mod tests {
use super::{FileTester, IsErr, IsFile, PathFlags, is_potential_path};
use crate::env::EnvStack;
use crate::operation_context::{EXPANSION_LIMIT_DEFAULT, OperationContext};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::redirection::RedirectionMode;
use std::fs::{self, File, Permissions, create_dir_all};

View File

@@ -1278,9 +1278,9 @@ mod tests {
use crate::future_feature_flags::{self, FeatureFlag};
use crate::highlight::parse_text_face_for_highlight;
use crate::operation_context::{EXPANSION_LIMIT_BACKGROUND, OperationContext};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::text_face::UnderlineStyle;
use crate::wchar::prelude::*;
use libc::PATH_MAX;
// Helper to return a string whose length greatly exceeds PATH_MAX.

View File

@@ -56,9 +56,9 @@
parse_constants::{ParseTreeFlags, StatementDecoration},
parse_util::{parse_util_detect_errors, parse_util_unescape_wildcards},
path::{path_get_config, path_get_data, path_is_valid},
prelude::*,
threads::assert_is_background_thread,
util::find_subslice,
wchar::prelude::*,
wcstringutil::subsequence_in_string,
wildcard::{ANY_STRING, wildcard_match},
wutil::{FileId, INVALID_FILE_ID, file_id_for_file, wgettext_fmt, wrealpath, wstat, wunlink},
@@ -1778,8 +1778,8 @@ mod tests {
use crate::env::{EnvMode, EnvStack};
use crate::fs::{LockedFile, WriteMethod};
use crate::path::path_get_data;
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wcstringutil::{string_prefixes_string, string_prefixes_string_case_insensitive};
use fish_build_helper::workspace_root;
use rand::Rng;

View File

@@ -7,9 +7,9 @@
R_END_INPUT_FUNCTIONS, ReadlineCmd, match_key_event_to_key,
};
use crate::key::{self, Key, Modifiers, canonicalize_raw_escapes, ctrl};
use crate::prelude::*;
use crate::reader::{Reader, reader_reset_interrupted};
use crate::threads::assert_is_main_thread;
use crate::wchar::prelude::*;
use once_cell::sync::Lazy;
use std::mem;
use std::sync::{
@@ -973,7 +973,7 @@ mod tests {
use crate::env::EnvStack;
use crate::input_common::{CharEvent, InputData, InputEventQueuer, KeyEvent};
use crate::key::Key;
use crate::wchar::prelude::*;
use crate::prelude::*;
struct TestInputEventQueuer {
input_data: InputData,

View File

@@ -10,13 +10,13 @@
self, Key, Modifiers, ViewportPosition, alt, canonicalize_control_char,
canonicalize_keyed_control_char, char_to_symbol, function_key, shift,
};
use crate::prelude::*;
use crate::reader::reader_test_and_clear_interrupted;
use crate::tty_handoff::{
SCROLL_CONTENT_UP_TERMINFO_CODE, TERMINAL_OS_NAME, XTGETTCAP_QUERY_OS_NAME, XTVERSION,
maybe_set_kitty_keyboard_capability, maybe_set_scroll_content_up_capability,
};
use crate::universal_notifier::default_notifier;
use crate::wchar::prelude::*;
use crate::wutil::{fish_is_pua, fish_wcstol};
use fish_wchar::encode_byte_to_char;
use std::cell::{RefCell, RefMut};

View File

@@ -7,12 +7,12 @@
use crate::flog::{flog, flogf, should_flog};
use crate::nix::isatty;
use crate::path::path_apply_working_directory;
use crate::prelude::*;
use crate::proc::JobGroupRef;
use crate::redirection::{RedirectionMode, RedirectionSpecList};
use crate::signal::SigChecker;
use crate::terminal::Output;
use crate::topic_monitor::Topic;
use crate::wchar::prelude::*;
use crate::wutil::{perror, perror_io, wdirname, wstat, wwrite_to_fd};
use errno::Errno;
use libc::{EAGAIN, EINTR, ENOENT, ENOTDIR, EPIPE, EWOULDBLOCK, STDOUT_FILENO};

View File

@@ -1,7 +1,7 @@
use crate::global_safety::RelaxedAtomicBool;
use crate::prelude::*;
use crate::proc::{JobGroupRef, Pid};
use crate::signal::Signal;
use crate::wchar::prelude::*;
use std::cell::RefCell;
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicI32, Ordering};

View File

@@ -4,8 +4,8 @@
common::{EscapeFlags, EscapeStringStyle, escape_string},
flog::FloggableDebug,
future_feature_flags::{FeatureFlag, test as feature_test},
prelude::*,
reader::safe_get_terminal_mode_on_startup,
wchar::prelude::*,
wutil::fish_wcstoul,
};
use fish_fallback::fish_wcwidth;
@@ -461,7 +461,7 @@ pub fn char_to_symbol(c: char, is_first_in_token: bool) -> WString {
#[cfg(test)]
mod tests {
use crate::key::{self, Key, ctrl, function_key, parse_keys};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_parse_key() {

View File

@@ -7,7 +7,7 @@
use std::collections::VecDeque;
use std::sync::Mutex;
use crate::wchar::prelude::*;
use crate::prelude::*;
struct KillRing(VecDeque<WString>);
@@ -86,7 +86,7 @@ pub fn kill_entries() -> Vec<WString> {
#[cfg(test)]
mod tests {
use super::KillRing;
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_killring() {

View File

@@ -52,6 +52,7 @@
pub mod parser;
pub mod parser_keywords;
pub mod path;
pub mod prelude;
pub mod print_help;
pub mod proc;
pub mod re;
@@ -73,7 +74,6 @@
pub mod universal_notifier;
pub mod util;
pub mod wait_handle;
pub mod wchar;
pub mod wcstringutil;
pub mod wgetopt;
pub mod wildcard;

View File

@@ -10,9 +10,9 @@
use crate::editable_line::EditableLine;
use crate::highlight::{HighlightRole, HighlightSpec, highlight_shell};
use crate::operation_context::OperationContext;
use crate::prelude::*;
use crate::screen::{CharOffset, Line, ScreenData, wcswidth_rendered, wcwidth_rendered};
use crate::termsize::Termsize;
use crate::wchar::prelude::*;
use crate::wcstringutil::string_fuzzy_match_string;
/// Represents rendering from the pager.
@@ -1279,9 +1279,9 @@ mod tests {
use super::{Pager, SelectionMotion};
use crate::common::get_ellipsis_char;
use crate::complete::{CompleteFlags, Completion};
use crate::prelude::*;
use crate::termsize::Termsize;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wcstringutil::StringFuzzyMatch;
use std::num::NonZeroU16;

View File

@@ -1,6 +1,6 @@
//! Constants used in the programmatic representation of fish code.
use crate::wchar::prelude::*;
use crate::prelude::*;
use bitflags::bitflags;
use fish_fallback::{fish_wcswidth, fish_wcwidth};

View File

@@ -38,6 +38,7 @@
use crate::parser::{Block, BlockData, BlockId, BlockType, LoopStatus, Parser, ProfileItem};
use crate::parser_keywords::parser_keywords_is_subcommand;
use crate::path::{path_as_implicit_cd, path_try_get_path};
use crate::prelude::*;
use crate::proc::{
ConcreteAssignment, Job, JobControl, JobProperties, JobRef, Process, ProcessType,
get_job_control_mode, job_reap, no_exec,
@@ -48,7 +49,6 @@
use crate::timer::push_timer;
use crate::tokenizer::{PipeOrRedir, TokenType, variable_assignment_equals_pos};
use crate::trace::{trace_if_enabled, trace_if_enabled_with_args};
use crate::wchar::prelude::*;
use crate::wildcard::wildcard_match;
use fish_wchar::WExt;
use libc::{ENOTDIR, EXIT_SUCCESS, STDERR_FILENO, STDOUT_FILENO, c_int};

View File

@@ -10,8 +10,8 @@
ParseErrorCode, ParseErrorList, ParseKeyword, ParseTokenType, ParseTreeFlags,
SOURCE_OFFSET_INVALID, SourceOffset, SourceRange, token_type_user_presentable_description,
};
use crate::prelude::*;
use crate::tokenizer::TokenizerError;
use crate::wchar::prelude::*;
use crate::wcstringutil::count_newlines;
/// A struct representing the token type that we use internally.

View File

@@ -22,11 +22,11 @@
ParseTokenType, ParseTreeFlags, ParserTestErrorBits, PipelinePosition, SourceRange,
StatementDecoration, UNKNOWN_BUILTIN_ERR_MSG, parse_error_offset_source_start,
};
use crate::prelude::*;
use crate::tokenizer::{
TOK_ACCEPT_UNFINISHED, TOK_SHOW_COMMENTS, Tok, TokenType, Tokenizer, comment_end,
is_token_delimiter, quote_end,
};
use crate::wchar::prelude::*;
use crate::wcstringutil::count_newlines;
use crate::wcstringutil::truncate;
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
@@ -1982,8 +1982,8 @@ mod tests {
ERROR_NO_VAR_NAME, ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR,
ERROR_NOT_PID, ERROR_NOT_STATUS,
};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use pcre2::utf32::Regex;
#[test]

View File

@@ -27,11 +27,11 @@
use crate::parse_execution::{EndExecutionReason, ExecutionContext};
use crate::parse_tree::NodeRef;
use crate::parse_tree::{LineCounter, ParsedSourceRef, parse_source};
use crate::prelude::*;
use crate::proc::{JobGroupRef, JobList, JobRef, Pid, ProcStatus, job_reap};
use crate::signal::{Signal, signal_check_cancel, signal_clear_cancel};
use crate::util::get_time;
use crate::wait_handle::WaitHandleStore;
use crate::wchar::prelude::*;
use crate::wutil::perror;
use crate::{flog, flogf, function};
use fish_wchar::WExt;
@@ -1448,10 +1448,10 @@ mod tests {
};
use crate::parse_tree::{LineCounter, parse_source};
use crate::parse_util::{parse_util_detect_errors, parse_util_detect_errors_in_argument};
use crate::prelude::*;
use crate::reader::{fake_scoped_reader, reader_reset_interrupted};
use crate::signal::{signal_clear_cancel, signal_reset_handlers, signal_set_handlers};
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wcstringutil::join_strings;
use libc::SIGINT;
use std::time::Duration;

View File

@@ -1,6 +1,6 @@
//! Functions having to do with parser keywords, like testing if a function is a block command.
use crate::wchar::prelude::*;
use crate::prelude::*;
struct ReservedWord {
text: &'static wstr,

View File

@@ -6,7 +6,7 @@
use crate::env::{EnvMode, EnvStack, Environment, FALLBACK_PATH};
use crate::expand::{HOME_DIRECTORY, expand_tilde};
use crate::flog::{flog, flogf};
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wstat};
use errno::{Errno, errno, set_errno};
use libc::{EACCES, ENOENT, ENOTDIR, F_OK, X_OK};
@@ -770,7 +770,7 @@ pub fn append_path_component(path: &mut WString, component: &wstr) {
#[cfg(test)]
mod tests {
use super::{path_apply_working_directory, path_make_canonical, paths_are_equivalent};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_path_make_canonical() {

5
src/prelude.rs Normal file
View File

@@ -0,0 +1,5 @@
pub use crate::wutil::{
LocalizableString, eprintf, localizable_consts, localizable_string, sprintf, wgettext,
wgettext_fmt,
};
pub use fish_wchar::prelude::*;

View File

@@ -1,7 +1,7 @@
//! Helper for executables (not builtins) to print a help message
//! Uses the fish in PATH, not necessarily the matching fish binary
use crate::wchar::prelude::*;
use crate::prelude::*;
use std::ffi::{OsStr, OsString};
use std::process::Command;

View File

@@ -14,12 +14,12 @@
use crate::job_group::{JobGroup, MaybeJobId};
use crate::parse_tree::NodeRef;
use crate::parser::{Block, Parser};
use crate::prelude::*;
use crate::reader::{fish_is_unwinding_for_exit, reader_schedule_prompt_repaint};
use crate::redirection::RedirectionSpecList;
use crate::signal::{Signal, signal_set_handlers_once};
use crate::topic_monitor::{GenerationsList, Topic, topic_monitor_principal};
use crate::wait_handle::{InternalJobId, WaitHandle, WaitHandleRef, WaitHandleStore};
use crate::wchar::prelude::*;
use crate::wutil::{wbasename, wperror};
use cfg_if::cfg_if;
use fish_wchar::ToWString;

View File

@@ -1,4 +1,4 @@
use crate::wchar::prelude::*;
use crate::prelude::*;
/// Adjust a pattern so that it is anchored at both beginning and end.
/// This is a workaround for the fact that PCRE2_ENDANCHORED is unavailable on pre-2017 PCRE2
@@ -23,7 +23,7 @@ pub fn to_boxed_chars(s: &wstr) -> Box<[char]> {
#[cfg(test)]
mod tests {
use super::{regex_make_anchored, to_boxed_chars};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_regex_make_anchored() {

View File

@@ -2,8 +2,8 @@
use crate::history::{self, History, HistorySearch, SearchDirection, SearchFlags, SearchType};
use crate::parse_constants::SourceRange;
use crate::prelude::*;
use crate::tokenizer::{TOK_ACCEPT_UNFINISHED, TokenType, Tokenizer};
use crate::wchar::prelude::*;
use crate::wcstringutil::ifind;
use std::collections::HashSet;
use std::ops::Range;

View File

@@ -112,6 +112,7 @@
parse_util_lineno, parse_util_locate_cmdsubst_range, parse_util_token_extent,
};
use crate::parser::{BlockType, EvalRes, Parser};
use crate::prelude::*;
use crate::proc::{
have_proc_stat, hup_jobs, is_interactive_session, job_reap, jobs_requiring_warning_on_exit,
print_exit_warning_for_jobs, proc_update_jiffies,
@@ -147,7 +148,6 @@
use crate::tty_handoff::{
TtyHandoff, get_tty_protocols_active, initialize_tty_protocols, safe_deactivate_tty_protocols,
};
use crate::wchar::prelude::*;
use crate::wcstringutil::CaseSensitivity;
use crate::wcstringutil::string_prefixes_string_maybe_case_insensitive;
use crate::wcstringutil::{
@@ -6889,8 +6889,8 @@ mod tests {
use super::{combine_command_and_autosuggestion, completion_apply_to_command_line};
use crate::complete::CompleteFlags;
use crate::operation_context::{OperationContext, no_cancel};
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
fn test_autosuggestion_combining() {

View File

@@ -1,7 +1,7 @@
//! This file supports specifying and applying redirections.
use crate::io::IoChain;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wutil::fish_wcstoi;
use nix::fcntl::OFlag;
use std::os::fd::RawFd;

View File

@@ -29,13 +29,13 @@
use crate::flog::{flog, flogf};
use crate::global_safety::RelaxedAtomicBool;
use crate::highlight::{HighlightColorResolver, HighlightRole, HighlightSpec};
use crate::prelude::*;
use crate::terminal::TerminalCommand::{
self, ClearToEndOfLine, ClearToEndOfScreen, CursorDown, CursorLeft, CursorMove, CursorRight,
CursorUp, EnterDimMode, ExitAttributeMode, Osc133PromptEnd, Osc133PromptStart, ScrollContentUp,
};
use crate::terminal::{BufferedOutputter, CardinalDirection, Output, Outputter, use_terminfo};
use crate::termsize::Termsize;
use crate::wchar::prelude::*;
use crate::wcstringutil::{fish_wcwidth_visible, string_prefixes_string};
use crate::wutil::fstat;
use fish_fallback::fish_wcwidth;
@@ -2175,11 +2175,11 @@ mod tests {
use crate::common::get_ellipsis_char;
use crate::highlight::HighlightSpec;
use crate::parse_util::parse_util_compute_indents;
use crate::prelude::*;
use crate::screen::{
LayoutCache, PromptCacheEntry, PromptLayout, ScreenLayout, compute_layout,
};
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wcstringutil::join_strings;
#[test]

View File

@@ -4,11 +4,11 @@
use crate::common::exit_without_destructors;
use crate::event::{enqueue_signal, is_signal_observed};
use crate::nix::getpid;
use crate::prelude::*;
use crate::reader::{reader_handle_sigint, reader_sighup, safe_restore_term_mode};
use crate::termsize::safe_termsize_invalidate_tty;
use crate::topic_monitor::{Generation, GenerationsList, Topic, topic_monitor_principal};
use crate::tty_handoff::{safe_deactivate_tty_protocols, safe_mark_tty_invalid};
use crate::wchar::prelude::*;
use crate::wutil::{fish_wcstoi, perror};
use errno::{errno, set_errno};
use once_cell::sync::Lazy;
@@ -570,7 +570,7 @@ fn from(value: Signal) -> Self {
#[cfg(test)]
mod tests {
use super::Signal;
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_signal_name() {

View File

@@ -4,10 +4,10 @@
use crate::common::{self, EscapeStringStyle, escape_string, wcs2bytes, wcs2bytes_appending};
use crate::flogf;
use crate::future_feature_flags::{self, FeatureFlag};
use crate::prelude::*;
use crate::screen::{is_dumb, only_grayscale};
use crate::text_face::{TextFace, TextStyling, UnderlineStyle};
use crate::threads::MainThread;
use crate::wchar::prelude::*;
use bitflags::bitflags;
use once_cell::sync::OnceCell;
use std::cell::{RefCell, RefMut};

View File

@@ -3,7 +3,7 @@
use crate::env::{EnvMode, EnvVar, Environment};
use crate::flog::flog;
use crate::parser::Parser;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wutil::fish_wcstoi;
use std::mem::MaybeUninit;
use std::num::NonZeroU16;

View File

@@ -3,10 +3,10 @@
use crate::env::{EnvMode, EnvVar, EnvVarFlags, Environment};
use crate::locale::set_libc_locales;
use crate::parser::{CancelBehavior, Parser};
use crate::prelude::*;
use crate::reader::{reader_deinit, reader_init};
use crate::signal::signal_reset_handlers;
use crate::topic_monitor::topic_monitor_init;
use crate::wchar::prelude::*;
use crate::wutil::wgetcwd;
use crate::{env::EnvStack, proc::proc_init};
use once_cell::sync::OnceCell;

View File

@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::prelude::*;
use crate::terminal::{self, get_color_support};
use crate::wchar::prelude::*;
use crate::wgetopt::{ArgType, WGetopter, WOption, wopt};
trait StyleSet {

View File

@@ -31,7 +31,7 @@
};
use crate::{
wchar::prelude::*,
prelude::*,
wutil::{Error as wcstodError, wcstod::wcstod_underscores, wgettext},
};

View File

@@ -6,9 +6,9 @@
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::parse_constants::SOURCE_OFFSET_INVALID;
use crate::parser_keywords::parser_keywords_is_subcommand;
use crate::prelude::*;
use crate::reader::is_backslashed;
use crate::redirection::RedirectionMode;
use crate::wchar::prelude::*;
use libc::{STDIN_FILENO, STDOUT_FILENO};
use nix::fcntl::OFlag;
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not, Range};
@@ -1410,8 +1410,8 @@ mod tests {
MoveWordStateMachine, MoveWordStyle, PipeOrRedir, TokFlags, TokenType, Tokenizer,
TokenizerError,
};
use crate::prelude::*;
use crate::redirection::RedirectionMode;
use crate::wchar::prelude::*;
use libc::{STDERR_FILENO, STDOUT_FILENO};
use std::collections::HashSet;

View File

@@ -1,6 +1,6 @@
use crate::flog::log_extra_to_flog_file;
use crate::parser::Parser;
use crate::{common::escape, global_safety::RelaxedAtomicBool, wchar::prelude::*};
use crate::{common::escape, global_safety::RelaxedAtomicBool, prelude::*};
static DO_TRACE: RelaxedAtomicBool = RelaxedAtomicBool::new(false);

View File

@@ -7,6 +7,7 @@
use crate::flog::{flog, flogf};
use crate::global_safety::RelaxedAtomicBool;
use crate::job_group::JobGroup;
use crate::prelude::*;
use crate::proc::JobGroupRef;
use crate::terminal::TerminalCommand::{
self, ApplicationKeypadModeDisable, ApplicationKeypadModeEnable, DecrstBracketedPaste,
@@ -16,7 +17,6 @@
};
use crate::terminal::{Output, Outputter};
use crate::threads::assert_is_main_thread;
use crate::wchar::prelude::*;
use crate::wutil::{perror, wcstoi};
use fish_wchar::ToWString;
use libc::{EINVAL, ENOTTY, EPERM, STDIN_FILENO, WNOHANG};

View File

@@ -1,7 +1,7 @@
use crate::common::wcs2osstring;
use crate::env_universal_common::default_vars_path;
use crate::prelude::*;
use crate::universal_notifier::UniversalNotifier;
use crate::wchar::prelude::*;
use crate::wutil::{wbasename, wdirname};
use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify};
use std::ffi::OsString;

View File

@@ -1,8 +1,8 @@
use crate::common::wcs2osstring;
use crate::env_universal_common::default_vars_path;
use crate::flogf;
use crate::prelude::*;
use crate::universal_notifier::UniversalNotifier;
use crate::wchar::prelude::*;
use crate::wutil::wdirname;
use nix::sys::event::{EvFlags, EventFilter, FilterFlag, KEvent, Kqueue};
use std::fs::File;

View File

@@ -1,8 +1,8 @@
use crate::common::PROGRAM_NAME;
use crate::fds::{make_fd_nonblocking, set_cloexec};
use crate::flog::{flog, flogf};
use crate::prelude::*;
use crate::universal_notifier::UniversalNotifier;
use crate::wchar::prelude::*;
use libc::{c_char, c_int};
use std::ffi::CString;
use std::os::fd::{BorrowedFd, RawFd};

View File

@@ -1,5 +1,5 @@
use super::UniversalNotifier;
use crate::wchar::prelude::*;
use crate::prelude::*;
// Helper to test a slice of notifiers.
// fish_variables_path is the path to the (simulated) fish_variables file, if using the inotify notifier.

View File

@@ -1,6 +1,6 @@
//! Generic utilities library.
use crate::wchar::prelude::*;
use crate::prelude::*;
use rand::{SeedableRng, rngs::SmallRng};
use std::cmp::Ordering;
use std::time;
@@ -260,7 +260,7 @@ pub fn find_subslice<T: PartialEq>(
#[cfg(test)]
mod tests {
use super::wcsfilecmp;
use crate::wchar::prelude::*;
use crate::prelude::*;
use std::cmp::Ordering;
/// Verify the behavior of the `wcsfilecmp()` function.

View File

@@ -1,5 +1,5 @@
use crate::prelude::*;
use crate::proc::Pid;
use crate::wchar::prelude::*;
use std::cell::Cell;
use std::rc::Rc;
@@ -124,8 +124,8 @@ pub fn size(&self) -> usize {
#[cfg(test)]
mod tests {
use super::{WaitHandle, WaitHandleStore};
use crate::prelude::*;
use crate::proc::Pid;
use crate::wchar::prelude::*;
#[test]
fn test_wait_handles() {

View File

@@ -1,7 +0,0 @@
pub mod prelude {
pub use crate::wutil::{
LocalizableString, eprintf, localizable_consts, localizable_string, sprintf, wgettext,
wgettext_fmt,
};
pub use fish_wchar::prelude::*;
}

View File

@@ -1,7 +1,7 @@
//! Helper functions for working with wcstring.
use crate::common::{get_ellipsis_char, get_ellipsis_str};
use crate::wchar::prelude::*;
use crate::prelude::*;
use fish_fallback::{fish_wcwidth, wcscasecmp, wcscasecmp_fuzzy};
use fish_wchar::decode_byte_from_char;
@@ -554,7 +554,7 @@ mod tests {
CaseSensitivity, ContainType, LineIterator, count_newlines, ifind, join_strings,
split_string_tok, string_fuzzy_match_string,
};
use crate::wchar::prelude::*;
use crate::prelude::*;
#[test]
fn test_ifind() {

View File

@@ -24,7 +24,7 @@
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
use crate::wchar::prelude::*;
use crate::prelude::*;
/// Special char used with [`Ordering::ReturnInOrder`].
pub const NON_OPTION_CHAR: char = '\x01';
@@ -567,7 +567,7 @@ fn wgetopt_inner(&mut self, longopt_index: &mut usize) -> Option<char> {
#[cfg(test)]
mod tests {
use super::{ArgType, WGetopter, WOption, wopt};
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wcstringutil::join_strings;
#[test]

View File

@@ -15,7 +15,7 @@
use crate::expand::ExpandFlags;
use crate::future_feature_flags::FeatureFlag;
use crate::future_feature_flags::feature_test;
use crate::wchar::prelude::*;
use crate::prelude::*;
use crate::wcstringutil::{
CaseSensitivity, string_fuzzy_match_string, string_suffixes_string_case_insensitive,
strip_executable_suffix,

View File

@@ -328,7 +328,7 @@ fn next(&mut self) -> Option<Self::Item> {
#[cfg(test)]
mod tests {
use super::{DirEntryType, DirIter};
use crate::wchar::prelude::*;
use crate::prelude::*;
use fish_wchar::L;
use nix::sys::stat::Mode;
use std::fs::File;

View File

@@ -2,7 +2,7 @@
#[cfg(feature = "localize-messages")]
use crate::env::{EnvStack, Environment};
use crate::wchar::prelude::*;
use crate::prelude::*;
use once_cell::sync::Lazy;
#[cfg(feature = "localize-messages")]
@@ -386,8 +386,8 @@ macro_rules! wgettext_fmt {
#[cfg(test)]
mod tests {
use super::LocalizableString;
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
#[test]
#[serial]

View File

@@ -475,8 +475,8 @@ mod tests {
use super::{normalize_path, wbasename, wdirname, wstr_offset_in, wwrite_to_fd};
use crate::common::bytes2wcstring;
use crate::fds::AutoCloseFd;
use crate::prelude::*;
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use libc::{O_CREAT, O_RDWR, O_TRUNC, SEEK_SET};
use rand::Rng;
use std::{ffi::CString, ptr};

View File

@@ -1,5 +1,5 @@
pub use super::errors::Error;
use crate::wchar::prelude::*;
use crate::prelude::*;
use num_traits::{NumCast, PrimInt};
use std::default::Default;
use std::iter::{Fuse, Peekable};