style: change rustfmt edition to 2024

This commit adds `style_edition = "2024"` as a rustfmt config setting.
All other changes are automatically generated by `cargo fmt`.

The 2024 style edition fixes several bugs and changes some defaults.
https://doc.rust-lang.org/edition-guide/rust-2024/rustfmt-style-edition.html

Most of the changes made to our code result from a different sorting
method for `use` statements, improved ability to split long lines, and
contraction of short trailing expressions into single-line expressions.

While our MSRV is still 1.70, we use more recent toolchains for
development, so we can already benefit from the improvements of the new
style edition. Formatting is not require for building fish, so builds
with Rust 1.70 are not affected by this change.

More context can be found at
https://github.com/fish-shell/fish-shell/issues/11630#issuecomment-3406937077

Closes #11959
This commit is contained in:
Daniel Rainer
2025-10-16 17:33:06 +02:00
committed by Johannes Altmanninger
parent 1c3a6a463d
commit 43f8d7478e
122 changed files with 508 additions and 500 deletions

1
.rustfmt.toml Normal file
View File

@@ -0,0 +1 @@
style_edition = "2024"

View File

@@ -57,7 +57,9 @@ fn main() {
detect_cfgs(&mut target);
#[cfg(all(target_env = "gnu", target_feature = "crt-static"))]
compile_error!("Statically linking against glibc has unavoidable crashes and is unsupported. Use dynamic linking or link statically against musl.");
compile_error!(
"Statically linking against glibc has unavoidable crashes and is unsupported. Use dynamic linking or link statically against musl."
);
}
/// Check target system support for certain functionality dynamically when the build is invoked,

View File

@@ -62,10 +62,14 @@ fn build_man(man_dir: &Path) {
{
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
if env_var("FISH_BUILD_DOCS") == Some("1".to_string()) {
panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0.");
panic!(
"Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0."
);
}
rsconf::warn!("Cannot find sphinx-build to build man pages.");
rsconf::warn!("If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly.");
rsconf::warn!(
"If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly."
);
return;
}
Err(e) => {

View File

@@ -50,7 +50,9 @@ fn append_po_entry_to_file(message: &TokenStream, file_name: &OsString) {
.unwrap_or_else(|e| panic!("Could not open file {file_name:?}: {e}"));
let message_string = unescape_multiline_rust_string(message.to_string());
if message_string.contains('\n') {
panic!("Gettext strings may not contain unescaped newlines. Unescaped newline found in '{message_string}'")
panic!(
"Gettext strings may not contain unescaped newlines. Unescaped newline found in '{message_string}'"
)
}
// Crude check for format strings. This might result in false positives.
let format_string_annotation = if message_string.contains('%') {
@@ -84,7 +86,9 @@ pub fn gettext_extract(message: TokenStream) -> TokenStream {
.next()
.expect("gettext_extract got empty token stream. Expected one token.");
if token_trees.next().is_some() {
panic!("Invalid number of tokens passed to gettext_extract. Expected one token, but got more.")
panic!(
"Invalid number of tokens passed to gettext_extract. Expected one token, but got more."
)
}
if let proc_macro2::TokenTree::Group(group) = first_token {
let mut group_tokens = group.stream().into_iter();
@@ -92,7 +96,9 @@ pub fn gettext_extract(message: TokenStream) -> TokenStream {
.next()
.expect("gettext_extract expected one group token but got none.");
if group_tokens.next().is_some() {
panic!("Invalid number of tokens in group passed to gettext_extract. Expected one token, but got more.")
panic!(
"Invalid number of tokens in group passed to gettext_extract. Expected one token, but got more."
)
}
if let proc_macro2::TokenTree::Literal(_) = first_group_token {
append_po_entry_to_file(&message, &file_path);

View File

@@ -3,8 +3,8 @@
mod tests;
use super::locale::Locale;
use super::printf_impl::{pad, ConversionSpec, Error, ModifierFlags};
use decimal::{Decimal, DigitLimit, DIGIT_WIDTH};
use super::printf_impl::{ConversionSpec, Error, ModifierFlags, pad};
use decimal::{DIGIT_WIDTH, Decimal, DigitLimit};
use std::cmp::min;
use std::fmt::Write;

View File

@@ -4,9 +4,9 @@
mod fmt_fp;
mod printf_impl;
pub use printf_impl::{sprintf_locale, Error, FormatString};
pub use printf_impl::{Error, FormatString, sprintf_locale};
pub mod locale;
pub use locale::{Locale, C_LOCALE, EN_US_LOCALE};
pub use locale::{C_LOCALE, EN_US_LOCALE, Locale};
#[cfg(test)]
mod tests;

View File

@@ -66,11 +66,7 @@ fn next_group_size(&self, digits_left: usize) -> usize {
// Divide remaining digits by repeat_group.
// Apply any remainder to the first group.
let res = (digits_left - accum) % (repeat_group as usize);
if res > 0 {
res
} else {
repeat_group as usize
}
if res > 0 { res } else { repeat_group as usize }
}
}

View File

@@ -1,6 +1,6 @@
use crate::arg::ToArg;
use crate::locale::{Locale, C_LOCALE, EN_US_LOCALE};
use crate::{sprintf_locale, Error, FormatString};
use crate::locale::{C_LOCALE, EN_US_LOCALE, Locale};
use crate::{Error, FormatString, sprintf_locale};
use libc::c_char;
use std::f64::consts::{E, PI, TAU};
use std::fmt;

View File

@@ -9,19 +9,19 @@
*
* Most clients will be interested in visiting the nodes of an ast.
*/
use crate::common::{unescape_string, UnescapeStringStyle};
use crate::common::{UnescapeStringStyle, unescape_string};
use crate::flog::{FLOG, FLOGF};
use crate::parse_constants::{
token_type_user_presentable_description, ParseError, ParseErrorCode, ParseErrorList,
ParseKeyword, ParseTokenType, ParseTreeFlags, SourceRange, StatementDecoration,
ERROR_BAD_COMMAND_ASSIGN_ERR_MSG, INVALID_PIPELINE_CMD_ERR_MSG, SOURCE_OFFSET_INVALID,
ERROR_BAD_COMMAND_ASSIGN_ERR_MSG, INVALID_PIPELINE_CMD_ERR_MSG, ParseError, ParseErrorCode,
ParseErrorList, ParseKeyword, ParseTokenType, ParseTreeFlags, SOURCE_OFFSET_INVALID,
SourceRange, StatementDecoration, token_type_user_presentable_description,
};
use crate::parse_tree::ParseToken;
#[cfg(test)]
use crate::tests::prelude::*;
use crate::tokenizer::{
variable_assignment_equals_pos, TokFlags, TokenType, Tokenizer, TokenizerError,
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;
@@ -1297,7 +1297,10 @@ pub fn parent(&self, node: &dyn Node) -> &'a dyn Node {
return iter.next().expect("Node is root and has no parent");
}
}
panic!("Node {:?} has either been popped off of the stack or not yet visited. Cannot find parent.", node.describe());
panic!(
"Node {:?} has either been popped off of the stack or not yet visited. Cannot find parent.",
node.describe()
);
}
// Skip the children of the last visited node, which must be passed

View File

@@ -1,17 +1,17 @@
//! The classes responsible for autoloading functions and completions.
use crate::FLOGF;
#[cfg(feature = "embed-data")]
use crate::common::wcs2string;
use crate::common::{escape, ScopeGuard};
use crate::common::{ScopeGuard, escape};
use crate::env::Environment;
use crate::io::IoChain;
use crate::parser::Parser;
#[cfg(test)]
use crate::tests::prelude::*;
use crate::wchar::{wstr, WString, L};
use crate::wchar::{L, WString, wstr};
use crate::wchar_ext::WExt;
use crate::wutil::{file_id_for_path, FileId, INVALID_FILE_ID};
use crate::FLOGF;
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_path};
use lru::LruCache;
#[cfg(feature = "embed-data")]
use rust_embed::RustEmbed;
@@ -521,9 +521,11 @@ fn touch_file(path: &wstr) {
let paths = &[p1.clone(), p2.clone()];
let mut autoload = Autoload::new(L!("test_var"));
assert!(autoload.resolve_command_impl(L!("file1"), paths).is_none());
assert!(autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none());
assert!(
autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none()
);
assert!(autoload.get_autoloaded_commands().is_empty());
run!("touch %s/file1.fish", p1);
@@ -549,9 +551,11 @@ fn touch_file(path: &wstr) {
autoload.resolve_command_impl(L!("file1"), paths),
AutoloadResult::Loaded
));
assert!(autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none());
assert!(
autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none()
);
assert!(autoload.resolve_command_impl(L!("file2"), paths).is_some());
assert!(matches!(
autoload.resolve_command_impl(L!("file2"), paths),
@@ -571,9 +575,11 @@ fn touch_file(path: &wstr) {
autoload.resolve_command_impl(L!("file1"), paths),
AutoloadResult::Loaded
));
assert!(autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none());
assert!(
autoload
.resolve_command_impl(L!("nothing"), paths)
.is_none()
);
assert!(autoload.resolve_command_impl(L!("file2"), paths).is_some());
assert!(matches!(
autoload.resolve_command_impl(L!("file2"), paths),

View File

@@ -31,21 +31,21 @@
},
},
common::{
escape, save_term_foreground_process_group, str2wcstring, wcs2string, PACKAGE_NAME,
PROFILING_ACTIVE, PROGRAM_NAME,
PACKAGE_NAME, PROFILING_ACTIVE, PROGRAM_NAME, escape, save_term_foreground_process_group,
str2wcstring, wcs2string,
},
env::{
config_paths::ConfigPaths,
environment::{env_init, EnvStack, Environment},
EnvMode, Statuses,
config_paths::ConfigPaths,
environment::{EnvStack, Environment, env_init},
},
eprintf,
event::{self, Event},
flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd, FLOG, FLOGF},
flog::{self, FLOG, FLOGF, activate_flog_categories_by_pattern, set_flog_file_fd},
fprintf, function, future_feature_flags as features,
history::{self, start_private_mode},
io::IoChain,
nix::{getpid, getrusage, isatty, RUsage},
nix::{RUsage, getpid, getrusage, isatty},
panic::panic_handler,
parse_constants::{ParseErrorList, ParseTreeFlags},
parse_tree::ParsedSource,
@@ -54,8 +54,8 @@
path::path_get_config,
printf,
proc::{
get_login, is_interactive_session, mark_login, mark_no_exec, proc_init,
set_interactive_session, Pid,
Pid, get_login, is_interactive_session, mark_login, mark_no_exec, proc_init,
set_interactive_session,
},
reader::{reader_init, reader_read, term_copy_modes},
signal::{signal_clear_cancel, signal_unblock_all},
@@ -71,8 +71,8 @@
use std::fs::File;
use std::os::unix::prelude::*;
use std::path::Path;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use std::{env, ops::ControlFlow};
#[cfg(feature = "embed-data")]
@@ -242,7 +242,7 @@ fn run_command_list(parser: &Parser, cmds: &[OsString]) -> Result<(), libc::c_in
}
fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow<i32, usize> {
use fish::wgetopt::{wopt, ArgType::*, WGetopter, WOption};
use fish::wgetopt::{ArgType::*, WGetopter, WOption, wopt};
const RUSAGE_ARG: char = 1 as char;
const PRINT_DEBUG_CATEGORIES_ARG: char = 2 as char;

View File

@@ -1,6 +1,6 @@
use super::prelude::*;
use crate::abbrs::{self, Abbreviation, Position};
use crate::common::{escape, escape_string, valid_func_name, EscapeStringStyle};
use crate::common::{EscapeStringStyle, escape, escape_string, valid_func_name};
use crate::env::{EnvMode, EnvStackSetResult};
use crate::re::{regex_make_anchored, to_boxed_chars};
use pcre2::utf32::{Regex, RegexBuilder};

View File

@@ -2,12 +2,12 @@
use super::prelude::*;
use crate::common::{
escape, escape_string, str2wcstring, valid_var_name, EscapeFlags, EscapeStringStyle,
EscapeFlags, EscapeStringStyle, escape, escape_string, str2wcstring, valid_var_name,
};
use crate::highlight::{colorize, highlight_shell};
use crate::input::{input_function_get_names, input_mappings, InputMappingSet, KeyNameStyle};
use crate::input::{InputMappingSet, KeyNameStyle, input_function_get_names, input_mappings};
use crate::key::{
self, char_to_symbol, function_key, parse_keys, Key, Modifiers, KEY_NAMES, MAX_FUNCTION_KEY,
self, KEY_NAMES, Key, MAX_FUNCTION_KEY, Modifiers, char_to_symbol, function_key, parse_keys,
};
use crate::nix::isatty;
use std::sync::MutexGuard;

View File

@@ -3,12 +3,12 @@
use super::prelude::*;
use crate::{
env::{EnvMode, Environment},
fds::{wopen_dir, BEST_O_SEARCH},
fds::{BEST_O_SEARCH, wopen_dir},
path::path_apply_cdpath,
wutil::{normalize_path, wperror, wreadlink},
};
use errno::Errno;
use libc::{fchdir, EACCES, ELOOP, ENOENT, ENOTDIR, EPERM};
use libc::{EACCES, ELOOP, ENOENT, ENOTDIR, EPERM, fchdir};
use std::{os::fd::AsRawFd, sync::Arc};
// The cd builtin. Changes the current directory to the one specified or to $HOME if none is

View File

@@ -1,12 +1,12 @@
use super::prelude::*;
use super::read::TokenOutputMode;
use crate::ast::{self, Kind, Leaf};
use crate::common::{unescape_string, UnescapeFlags, UnescapeStringStyle};
use crate::common::{UnescapeFlags, UnescapeStringStyle, unescape_string};
use crate::complete::Completion;
use crate::expand::{expand_string, ExpandFlags, ExpandResultCode};
use crate::expand::{ExpandFlags, ExpandResultCode, expand_string};
use crate::input::input_function_get_code;
use crate::input_common::{CharEvent, ReadlineCmd};
use crate::operation_context::{no_cancel, OperationContext};
use crate::operation_context::{OperationContext, no_cancel};
use crate::parse_constants::{ParseTreeFlags, ParserTestErrorBits};
use crate::parse_util::{
parse_util_detect_errors, parse_util_get_offset_from_line, parse_util_job_extent,

View File

@@ -1,6 +1,6 @@
use super::prelude::*;
use crate::common::{unescape_string, ScopeGuard, UnescapeFlags, UnescapeStringStyle};
use crate::complete::{complete_add_wrapper, complete_remove_wrapper, CompletionRequestOptions};
use crate::common::{ScopeGuard, UnescapeFlags, UnescapeStringStyle, unescape_string};
use crate::complete::{CompletionRequestOptions, complete_add_wrapper, complete_remove_wrapper};
use crate::highlight::colorize;
use crate::highlight::highlight_shell;
use crate::nix::isatty;
@@ -14,8 +14,8 @@
use crate::{
common::str2wcstring,
complete::{
complete_add, complete_print, complete_remove, complete_remove_all, CompleteFlags,
CompleteOptionType, CompletionMode,
CompleteFlags, CompleteOptionType, CompletionMode, complete_add, complete_print,
complete_remove, complete_remove_all,
},
};
use libc::STDOUT_FILENO;

View File

@@ -3,7 +3,7 @@
use super::prelude::*;
use crate::io::IoStreams;
use crate::parser::Parser;
use crate::proc::{add_disowned_job, Job};
use crate::proc::{Job, add_disowned_job};
use crate::{builtins::shared::HelpOnlyCmdOpts, wchar::wstr, wutil::wgettext_fmt};
use libc::SIGCONT;

View File

@@ -17,27 +17,27 @@
use super::prelude::*;
use crate::ast::{self, Ast, Kind, Leaf, Node, NodeVisitor, SourceRangeList, Traversal};
use crate::common::{
str2wcstring, unescape_string, wcs2string, UnescapeFlags, UnescapeStringStyle, PROGRAM_NAME,
PROGRAM_NAME, UnescapeFlags, UnescapeStringStyle, str2wcstring, unescape_string, wcs2string,
};
use crate::env::EnvStack;
use crate::env::env_init;
use crate::env::environment::Environment;
use crate::env::EnvStack;
use crate::expand::INTERNAL_SEPARATOR;
#[allow(unused_imports)]
use crate::future::{IsSomeAnd, IsSorted};
use crate::future_feature_flags;
use crate::global_safety::RelaxedAtomicBool;
use crate::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec};
use crate::highlight::{HighlightRole, HighlightSpec, colorize, highlight_shell};
use crate::operation_context::OperationContext;
use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange};
use crate::parse_util::{apply_indents, parse_util_compute_indents, SPACES_PER_INDENT};
use crate::parse_util::{SPACES_PER_INDENT, apply_indents, parse_util_compute_indents};
use crate::print_help::print_help;
use crate::threads;
use crate::tokenizer::{TokenType, Tokenizer, TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS};
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::{wopt, ArgType, WGetopter, WOption};
use crate::wgetopt::{ArgType, WGetopter, WOption, wopt};
use crate::wutil::fish_iswalnum;
/// Note: this got somewhat more complicated after introducing the new AST, because that AST no

View File

@@ -15,14 +15,14 @@
use crate::future::IsSomeAnd;
use crate::{
builtins::shared::BUILTIN_ERR_UNKNOWN,
common::{shell_modes, str2wcstring, PROGRAM_NAME},
env::{env_init, EnvStack, Environment},
common::{PROGRAM_NAME, shell_modes, str2wcstring},
env::{EnvStack, Environment, env_init},
future_feature_flags,
input_common::{
match_key_event_to_key, CharEvent, ImplicitEvent, InputEventQueue, InputEventQueuer,
KeyEvent, QueryResultEvent,
CharEvent, ImplicitEvent, InputEventQueue, InputEventQueuer, KeyEvent, QueryResultEvent,
match_key_event_to_key,
},
key::{char_to_symbol, Key},
key::{Key, char_to_symbol},
nix::isatty,
panic::panic_handler,
print_help::print_help,
@@ -34,7 +34,7 @@
topic_monitor::topic_monitor_init,
tty_handoff::TtyHandoff,
wchar::prelude::*,
wgetopt::{wopt, ArgType, WGetopter, WOption},
wgetopt::{ArgType, WGetopter, WOption, wopt},
};
use super::prelude::*;

View File

@@ -1,7 +1,7 @@
//! Implementation of the history builtin.
use crate::history::in_private_mode;
use crate::history::{self, history_session_id, History};
use crate::history::{self, History, history_session_id};
use crate::reader::commandline_get_state;
use super::prelude::*;

View File

@@ -1,16 +1,16 @@
// Functions for executing the jobs builtin.
use super::prelude::*;
use crate::common::{escape_string, timef, EscapeFlags, EscapeStringStyle};
use crate::common::{EscapeFlags, EscapeStringStyle, escape_string, timef};
use crate::io::IoStreams;
use crate::job_group::{JobId, MaybeJobId};
use crate::parser::Parser;
use crate::proc::{clock_ticks_to_seconds, have_proc_stat, proc_get_jiffies, Job};
use crate::proc::{Job, clock_ticks_to_seconds, have_proc_stat, proc_get_jiffies};
use crate::wchar_ext::WExt;
use crate::wgetopt::{wopt, ArgType, WGetopter, WOption};
use crate::wgetopt::{ArgType, WGetopter, WOption, wopt};
use crate::wutil::wgettext;
use crate::{
wchar::{wstr, WString, L},
wchar::{L, WString, wstr},
wutil::{fish_wcstoi, wgettext_fmt},
};
use std::num::NonZeroU32;

View File

@@ -63,9 +63,8 @@ mod prelude {
parser::Parser,
wchar::prelude::*,
wgetopt::{
wopt,
ArgType::{self, *},
WGetopter, WOption, NON_OPTION_CHAR,
NON_OPTION_CHAR, WGetopter, WOption, wopt,
},
wutil::{fish_wcstoi, fish_wcstol, fish_wcstoul},
};

View File

@@ -9,11 +9,11 @@
use crate::util::wcsfilecmp_glob;
use crate::wcstringutil::split_string_tok;
use crate::wutil::{
file_id_for_path, lwstat, normalize_path, waccess, wbasename, wdirname, wrealpath, wstat,
INVALID_FILE_ID,
INVALID_FILE_ID, file_id_for_path, lwstat, normalize_path, waccess, wbasename, wdirname,
wrealpath, wstat,
};
use bitflags::bitflags;
use libc::{mode_t, F_OK, PATH_MAX, R_OK, S_ISGID, S_ISUID, W_OK, X_OK};
use libc::{F_OK, PATH_MAX, R_OK, S_ISGID, S_ISUID, W_OK, X_OK, mode_t};
macro_rules! path_error {
(

View File

@@ -49,15 +49,15 @@
// This file has been imported from source code of printf command in GNU Coreutils version 6.9.
use super::prelude::*;
use crate::locale::{get_numeric_locale, Locale};
use crate::locale::{Locale, get_numeric_locale};
use crate::wchar::encode_byte_to_char;
use crate::wutil::{
errors::Error,
wcstod::wcstod,
wcstoi::{wcstoi_partial, Options as WcstoiOpts},
wcstoi::{Options as WcstoiOpts, wcstoi_partial},
wstr_offset_in,
};
use fish_printf::{sprintf_locale, ToArg};
use fish_printf::{ToArg, sprintf_locale};
/// Return true if `c` is an octal digit.
fn is_octal_digit(c: char) -> bool {

View File

@@ -1,28 +1,28 @@
//! Implementation of the read builtin.
use super::prelude::*;
use crate::common::UnescapeStringStyle;
use crate::common::escape;
use crate::common::read_blocked;
use crate::common::str2wcstring;
use crate::common::unescape_string;
use crate::common::valid_var_name;
use crate::common::UnescapeStringStyle;
use crate::env::EnvMode;
use crate::env::Environment;
use crate::env::READ_BYTE_LIMIT;
use crate::env::{EnvVar, EnvVarFlags};
use crate::input_common::decode_input_byte;
use crate::input_common::DecodeState;
use crate::input_common::InvalidPolicy;
use crate::input_common::decode_input_byte;
use crate::nix::isatty;
use crate::reader::ReaderConfig;
use crate::reader::commandline_set_buffer;
use crate::reader::reader_save_screen_state;
use crate::reader::ReaderConfig;
use crate::reader::{reader_pop, reader_push, reader_readline};
use crate::tokenizer::Tok;
use crate::tokenizer::Tokenizer;
use crate::tokenizer::TOK_ACCEPT_UNFINISHED;
use crate::tokenizer::TOK_ARGUMENT_LIST;
use crate::tokenizer::Tok;
use crate::tokenizer::Tokenizer;
use crate::tty_handoff::TtyHandoff;
use crate::wcstringutil::split_about;
use crate::wcstringutil::split_string_tok;

View File

@@ -94,7 +94,7 @@ pub fn parse_return_value(
let (opts, optind) = match parse_options(args, parser, streams) {
ControlFlow::Continue(o) => o,
ControlFlow::Break(error_code) => {
return ControlFlow::Break(BuiltinResult::Err(error_code))
return ControlFlow::Break(BuiltinResult::Err(error_code));
}
};

View File

@@ -1,11 +1,11 @@
use super::prelude::*;
use crate::common::EscapeFlags;
use crate::common::EscapeStringStyle;
use crate::common::escape;
use crate::common::escape_string;
use crate::common::get_ellipsis_char;
use crate::common::get_ellipsis_str;
use crate::common::valid_var_name;
use crate::common::EscapeFlags;
use crate::common::EscapeStringStyle;
use crate::env::EnvStackSetResult;
use crate::env::EnvVarFlags;
use crate::env::INHERITED_VARS;
@@ -13,8 +13,8 @@
use crate::event::Event;
use crate::expand::expand_escape_string;
use crate::expand::expand_escape_variable;
use crate::history::history_session_id;
use crate::history::History;
use crate::history::history_session_id;
use crate::{
env::{EnvMode, EnvVar, Environment},
wutil::wcstoi::wcstoi_partial,

View File

@@ -4,9 +4,9 @@
use crate::color::Color;
use crate::common::str2wcstring;
use crate::screen::{is_dumb, only_grayscale};
use crate::terminal::{use_terminfo, Outputter};
use crate::terminal::{Outputter, use_terminfo};
use crate::text_face::{
self, parse_text_face_and_options, PrintColorsArgs, SpecifiedTextFace, TextFace, TextStyling,
self, PrintColorsArgs, SpecifiedTextFace, TextFace, TextStyling, parse_text_face_and_options,
};
fn print_colors(

View File

@@ -1,10 +1,10 @@
use super::prelude::*;
use crate::common::{escape, get_by_sorted_name, str2wcstring, Named};
use crate::common::{Named, escape, get_by_sorted_name, str2wcstring};
use crate::io::OutputStream;
use crate::parse_constants::UNKNOWN_BUILTIN_ERR_MSG;
use crate::parse_util::parse_util_argument_is_help;
use crate::parser::{BlockType, LoopStatus};
use crate::proc::{no_exec, Pid, ProcStatus};
use crate::proc::{Pid, ProcStatus, no_exec};
use crate::wchar::L;
use crate::{builtins::*, wutil};
use errno::errno;
@@ -125,11 +125,7 @@ pub trait BuiltinResultExt {
impl BuiltinResultExt for BuiltinResult {
fn from_dynamic(code: c_int) -> Self {
if code == 0 {
Ok(SUCCESS)
} else {
Err(code)
}
if code == 0 { Ok(SUCCESS) } else { Err(code) }
}
fn builtin_status_code(&self) -> c_int {
match self {

View File

@@ -1,7 +1,7 @@
use std::os::fd::AsRawFd;
use crate::{
common::{escape, FilenameRef},
common::{FilenameRef, escape},
fds::wopen_cloexec,
nix::isatty,
parser::Block,

View File

@@ -1,17 +1,17 @@
use std::os::unix::prelude::*;
use super::prelude::*;
use crate::common::{get_executable_path, str2wcstring, PROGRAM_NAME};
use crate::common::{PROGRAM_NAME, get_executable_path, str2wcstring};
use crate::future_feature_flags::{self as features, feature_test};
use crate::proc::{
get_job_control_mode, get_login, is_interactive_session, set_job_control_mode, JobControl,
JobControl, get_job_control_mode, get_login, is_interactive_session, set_job_control_mode,
};
use crate::reader::reader_in_interactive_read;
use crate::tty_handoff::{get_scroll_content_up_capability, xtversion};
use crate::wutil::{waccess, wbasename, wdirname, wrealpath, Error};
use crate::wutil::{Error, waccess, wbasename, wdirname, wrealpath};
use libc::F_OK;
use nix::errno::Errno;
use nix::NixPath;
use nix::errno::Errno;
macro_rules! str_enum {
($name:ident, $(($val:ident, $str:expr)),* $(,)?) => {

View File

@@ -1,5 +1,5 @@
use super::*;
use crate::common::{escape_string, EscapeFlags, EscapeStringStyle};
use crate::common::{EscapeFlags, EscapeStringStyle, escape_string};
#[derive(Default)]
pub struct Escape {

View File

@@ -6,7 +6,7 @@
use crate::env::{EnvMode, EnvVar, EnvVarFlags};
use crate::flog::FLOG;
use crate::parse_util::parse_util_unescape_wildcards;
use crate::wildcard::{wildcard_match, ANY_STRING};
use crate::wildcard::{ANY_STRING, wildcard_match};
#[derive(Default)]
pub struct Match<'args> {

View File

@@ -3,7 +3,7 @@
use pcre2::utf32::{Regex, RegexBuilder};
use super::*;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, feature_test};
#[derive(Default)]
pub struct Replace<'args> {

View File

@@ -1,5 +1,5 @@
use super::*;
use crate::common::{unescape_string, UnescapeStringStyle};
use crate::common::{UnescapeStringStyle, unescape_string};
#[derive(Default)]
pub struct Unescape {

View File

@@ -1,6 +1,6 @@
use super::prelude::*;
use crate::common;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::should_flog;
mod test_expressions {
@@ -8,8 +8,8 @@ mod test_expressions {
use crate::nix::isatty;
use crate::wutil::{
file_id_for_path, fish_wcswidth, lwstat, waccess, wcstod::wcstod, wcstoi_opts, wstat,
Error, Options,
Error, Options, file_id_for_path, fish_wcswidth, lwstat, waccess, wcstod::wcstod,
wcstoi_opts, wstat,
};
use once_cell::sync::Lazy;
use std::collections::HashMap;

View File

@@ -11,7 +11,7 @@ fn test_string() {
};
use crate::builtins::string::string;
use crate::common::escape;
use crate::future_feature_flags::{scoped_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, scoped_test};
use crate::io::{IoStreams, OutputStream, StringOutputStream};
use crate::tests::prelude::*;
use crate::wchar::prelude::*;

View File

@@ -1,6 +1,6 @@
use std::cmp::Ordering;
use libc::{c_uint, rlim_t, RLIM_INFINITY};
use libc::{RLIM_INFINITY, c_uint, rlim_t};
use nix::errno::Errno;
use once_cell::sync::Lazy;

View File

@@ -1,5 +1,5 @@
use super::prelude::*;
use crate::proc::{proc_wait_any, Job, Pid};
use crate::proc::{Job, Pid, proc_wait_any};
use crate::signal::SigChecker;
use crate::wait_handle::{WaitHandleRef, WaitHandleStore};

View File

@@ -5,7 +5,7 @@
PROCESS_EXPAND_SELF, PROCESS_EXPAND_SELF_STR, VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE,
};
use crate::fallback::fish_wcwidth;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::global_safety::AtomicRef;
use crate::global_safety::RelaxedAtomicBool;
use crate::key;
@@ -17,11 +17,11 @@
use crate::wcstringutil::wcs2string_callback;
use crate::wildcard::{ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::encoding::{
mbrtowc, probe_is_multibyte_locale, wcrtomb, zero_mbstate, AT_LEAST_MB_LEN_MAX,
AT_LEAST_MB_LEN_MAX, mbrtowc, probe_is_multibyte_locale, wcrtomb, zero_mbstate,
};
use crate::wutil::fish_iswalnum;
use bitflags::bitflags;
use libc::{SIGTTOU, SIG_IGN, STDIN_FILENO};
use libc::{SIG_IGN, SIGTTOU, STDIN_FILENO};
use once_cell::sync::OnceCell;
use std::cell::{Cell, RefCell};
use std::env;

View File

@@ -3,8 +3,8 @@
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
mem,
sync::{
atomic::{self, AtomicUsize},
Mutex, MutexGuard,
atomic::{self, AtomicUsize},
},
time::{Duration, Instant},
};
@@ -14,7 +14,7 @@
common::charptr2wcstring,
reader::{get_quote, is_backslashed},
util::wcsfilecmp,
wutil::{localizable_string, LocalizableString},
wutil::{LocalizableString, localizable_string},
};
use bitflags::bitflags;
use once_cell::sync::Lazy;
@@ -24,18 +24,18 @@
autoload::Autoload,
builtins::shared::{builtin_exists, builtin_get_desc, builtin_get_names},
common::{
escape, unescape_string, valid_var_name_char, ScopeGuard, UnescapeFlags,
UnescapeStringStyle,
ScopeGuard, UnescapeFlags, UnescapeStringStyle, escape, unescape_string,
valid_var_name_char,
},
env::{EnvMode, EnvStack, Environment},
exec::exec_subshell,
expand::{
expand_escape_string, expand_escape_variable, expand_one, expand_string,
expand_to_receiver, ExpandFlags, ExpandResultCode,
ExpandFlags, ExpandResultCode, expand_escape_string, expand_escape_variable, expand_one,
expand_string, expand_to_receiver,
},
flog::{FLOG, FLOGF},
function,
history::{history_session_id, History},
history::{History, history_session_id},
operation_context::OperationContext,
parse_constants::SourceRange,
parse_util::{
@@ -44,12 +44,12 @@
parser::{Block, Parser},
parser_keywords::parser_keywords_is_subcommand,
path::{path_get_path, path_try_get_path},
tokenizer::{variable_assignment_equals_pos, Tok, TokFlags, TokenType, Tokenizer},
tokenizer::{Tok, TokFlags, TokenType, Tokenizer, variable_assignment_equals_pos},
wchar::prelude::*,
wchar_ext::WExt,
wcstringutil::{
string_fuzzy_match_string, string_prefixes_string, string_prefixes_string_case_insensitive,
StringFuzzyMatch,
StringFuzzyMatch, string_fuzzy_match_string, string_prefixes_string,
string_prefixes_string_case_insensitive,
},
wildcard::{wildcard_complete, wildcard_has, wildcard_match},
wutil::wrealpath,

View File

@@ -1,7 +1,7 @@
use crate::common::wcs2string;
use crate::common::BUILD_DIR;
use crate::common::wcs2string;
use crate::wchar::prelude::*;
use crate::{common::get_executable_path, FLOG, FLOGF};
use crate::{FLOG, FLOGF, common::get_executable_path};
use fish_build_helper::workspace_root;
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;

View File

@@ -1,18 +1,18 @@
use super::environment_impl::{
colon_split, uvars, EnvMutex, EnvMutexGuard, EnvScopedImpl, EnvStackImpl, ModResult,
UVAR_SCOPE_IS_GLOBAL,
};
use super::ElectricVar;
use crate::abbrs::{abbrs_get_set, Abbreviation, Position};
use super::environment_impl::{
EnvMutex, EnvMutexGuard, EnvScopedImpl, EnvStackImpl, ModResult, UVAR_SCOPE_IS_GLOBAL,
colon_split, uvars,
};
use crate::abbrs::{Abbreviation, Position, abbrs_get_set};
use crate::builtins::shared::{BuiltinResult, SUCCESS};
use crate::common::{str2wcstring, unescape_string, wcs2zstring, UnescapeStringStyle};
use crate::common::{UnescapeStringStyle, str2wcstring, unescape_string, wcs2zstring};
use crate::env::config_paths::ConfigPaths;
use crate::env::{EnvMode, EnvVar, Statuses};
use crate::env_dispatch::{env_dispatch_init, env_dispatch_var_change};
use crate::event::Event;
use crate::flog::FLOG;
use crate::global_safety::RelaxedAtomicBool;
use crate::input::{init_input, FISH_BIND_MODE_VAR};
use crate::input::{FISH_BIND_MODE_VAR, init_input};
use crate::nix::{geteuid, getpid};
use crate::null_terminated_array::OwningNullTerminatedArray;
use crate::path::{
@@ -441,11 +441,7 @@ fn get_hostname_identifier() -> Option<WString> {
let cstr = unsafe { CStr::from_ptr(b.as_ptr()) };
let res = str2wcstring(cstr.to_bytes());
if res.is_empty() {
None
} else {
Some(res)
}
if res.is_empty() { None } else { Some(res) }
} else {
None
}

View File

@@ -1,12 +1,12 @@
use crate::common::wcs2zstring;
use crate::env::{
is_read_only, ElectricVar, EnvMode, EnvStackSetResult, EnvVar, EnvVarFlags, Statuses, VarTable,
ELECTRIC_VARIABLES, PATH_ARRAY_SEP,
ELECTRIC_VARIABLES, ElectricVar, EnvMode, EnvStackSetResult, EnvVar, EnvVarFlags,
PATH_ARRAY_SEP, Statuses, VarTable, is_read_only,
};
use crate::env_universal_common::EnvUniversal;
use crate::flog::FLOG;
use crate::global_safety::RelaxedAtomicBool;
use crate::history::{history_session_id_from_var, History};
use crate::history::{History, history_session_id_from_var};
use crate::kill::kill_entries;
use crate::nix::umask;
use crate::null_terminated_array::OwningNullTerminatedArray;
@@ -27,7 +27,7 @@
use portable_atomic::AtomicU64;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::{atomic::Ordering, Arc, Mutex, MutexGuard};
use std::sync::{Arc, Mutex, MutexGuard, atomic::Ordering};
/// Getter for universal variables.
/// This is typically initialized in env_init(), and is considered empty before then.
@@ -222,7 +222,7 @@ impl Deref for EnvNodeRef {
type Target = RefCell<EnvNode>;
fn deref(&self) -> &Self::Target {
&self.0 .0
&self.0.0
}
}

2
src/env/mod.rs vendored
View File

@@ -5,7 +5,7 @@
use crate::common::ToCString;
pub use environment::*;
use std::sync::{atomic::AtomicUsize, Mutex};
use std::sync::{Mutex, atomic::AtomicUsize};
pub use var::*;
/// Limit `read` to 1 GiB (bytes, not wide chars) by default. This can be overridden with the

2
src/env/var.rs vendored
View File

@@ -1,5 +1,5 @@
use crate::signal::Signal;
use crate::wchar::{wstr, WString, L};
use crate::wchar::{L, WString, wstr};
use crate::wcstringutil::join_strings;
use bitflags::bitflags;
use libc::c_int;

View File

@@ -1,6 +1,6 @@
use crate::complete::complete_invalidate_path;
use crate::env::{setenv_lock, unsetenv_lock, EnvMode, EnvStack, Environment};
use crate::env::{DEFAULT_READ_BYTE_LIMIT, READ_BYTE_LIMIT};
use crate::env::{EnvMode, EnvStack, Environment, setenv_lock, unsetenv_lock};
use crate::flog::FLOG;
use crate::input_common::{update_wait_on_escape_ms, update_wait_on_sequence_key_ms};
use crate::reader::{
@@ -8,10 +8,10 @@
reader_schedule_prompt_repaint, reader_set_autosuggestion_enabled, reader_set_transient_prompt,
};
use crate::screen::{
screen_set_midnight_commander_hack, IS_DUMB, LAYOUT_CACHE_SHARED, ONLY_GRAYSCALE,
IS_DUMB, LAYOUT_CACHE_SHARED, ONLY_GRAYSCALE, screen_set_midnight_commander_hack,
};
use crate::terminal::use_terminfo;
use crate::terminal::ColorSupport;
use crate::terminal::use_terminfo;
use crate::tty_handoff::xtversion;
use crate::wchar::prelude::*;
use crate::wutil::encoding::probe_is_multibyte_locale;

View File

@@ -1,17 +1,17 @@
#![allow(clippy::bad_bit_mask)]
use crate::common::{
unescape_string, valid_var_name, wcs2zstring, UnescapeFlags, UnescapeStringStyle,
UnescapeFlags, UnescapeStringStyle, unescape_string, valid_var_name, wcs2zstring,
};
use crate::env::{EnvVar, EnvVarFlags, VarTable};
use crate::flog::{FLOG, FLOGF};
use crate::fs::{lock_and_load, rewrite_via_temporary_file, PotentialUpdate};
use crate::fs::{PotentialUpdate, lock_and_load, rewrite_via_temporary_file};
use crate::path::path_get_config;
use crate::wchar::{decode_byte_from_char, prelude::*};
use crate::wcstringutil::{join_strings, LineIterator};
use crate::wutil::{file_id_for_file, file_id_for_path_narrow, wrealpath, FileId, INVALID_FILE_ID};
use std::collections::hash_map::Entry;
use crate::wcstringutil::{LineIterator, join_strings};
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_file, file_id_for_path_narrow, wrealpath};
use std::collections::HashSet;
use std::collections::hash_map::Entry;
use std::ffi::CString;
use std::fs::File;
use std::io::{Read, Write};

View File

@@ -7,13 +7,13 @@
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::{Arc, Mutex};
use crate::common::{escape, ScopeGuard};
use crate::common::{ScopeGuard, escape};
use crate::flog::FLOG;
use crate::io::{IoChain, IoStreams};
use crate::job_group::MaybeJobId;
use crate::parser::{Block, Parser};
use crate::proc::Pid;
use crate::signal::{signal_check_cancel, signal_handle, Signal};
use crate::signal::{Signal, signal_check_cancel, signal_handle};
use crate::termsize;
use crate::wchar::prelude::*;

View File

@@ -4,19 +4,20 @@
// performed have been massive.
use crate::builtins::shared::{
builtin_run, ErrorCode, STATUS_CMD_ERROR, STATUS_CMD_UNKNOWN, STATUS_NOT_EXECUTABLE,
STATUS_READ_TOO_MUCH,
ErrorCode, STATUS_CMD_ERROR, STATUS_CMD_UNKNOWN, STATUS_NOT_EXECUTABLE, STATUS_READ_TOO_MUCH,
builtin_run,
};
use crate::common::{
exit_without_destructors, str2wcstring, truncate_at_nul, wcs2string, wcs2zstring, write_loop,
ScopeGuard,
ScopeGuard, exit_without_destructors, str2wcstring, truncate_at_nul, wcs2string, wcs2zstring,
write_loop,
};
use crate::env::{EnvMode, EnvStack, Environment, Statuses, READ_BYTE_LIMIT};
use crate::env::{EnvMode, EnvStack, Environment, READ_BYTE_LIMIT, Statuses};
#[cfg(FISH_USE_POSIX_SPAWN)]
use crate::env_dispatch::use_posix_spawn;
use crate::fds::make_fd_blocking;
use crate::fds::{make_autoclose_pipes, open_cloexec, PIPE_ERROR};
use crate::fds::{PIPE_ERROR, make_autoclose_pipes, open_cloexec};
use crate::flog::{FLOG, FLOGF};
use crate::fork_exec::PATH_BSHELL;
use crate::fork_exec::blocked_signals_for_job;
use crate::fork_exec::postfork::{
child_setup_process, execute_fork, execute_setpgid, report_setpgid_error,
@@ -24,7 +25,6 @@
};
#[cfg(FISH_USE_POSIX_SPAWN)]
use crate::fork_exec::spawn::PosixSpawner;
use crate::fork_exec::PATH_BSHELL;
use crate::function::{self, FunctionProperties};
use crate::io::{
BufferedOutputStream, FdOutputStream, IoBufferfill, IoChain, IoClose, IoMode, IoPipe,
@@ -36,11 +36,11 @@
#[cfg(FISH_USE_POSIX_SPAWN)]
use crate::proc::Pid;
use crate::proc::{
hup_jobs, is_interactive_session, jobs_requiring_warning_on_exit, no_exec,
print_exit_warning_for_jobs, InternalProc, Job, JobGroupRef, ProcStatus, Process, ProcessType,
InternalProc, Job, JobGroupRef, ProcStatus, Process, ProcessType, hup_jobs,
is_interactive_session, jobs_requiring_warning_on_exit, no_exec, print_exit_warning_for_jobs,
};
use crate::reader::{reader_run_count, safe_restore_term_mode};
use crate::redirection::{dup2_list_resolve_chain, Dup2List};
use crate::redirection::{Dup2List, dup2_list_resolve_chain};
use crate::threads::{iothread_perform_cant_wait, is_forked_child};
use crate::trace::trace_if_enabled_with_args;
use crate::tty_handoff::TtyHandoff;
@@ -49,8 +49,8 @@
use crate::wutil::{fish_wcstol, perror};
use errno::{errno, set_errno};
use libc::{
c_char, EACCES, ENOENT, ENOEXEC, ENOTDIR, EPIPE, EXIT_FAILURE, EXIT_SUCCESS, STDERR_FILENO,
STDIN_FILENO, STDOUT_FILENO,
EACCES, ENOENT, ENOEXEC, ENOTDIR, EPIPE, EXIT_FAILURE, EXIT_SUCCESS, STDERR_FILENO,
STDIN_FILENO, STDOUT_FILENO, c_char,
};
use nix::fcntl::OFlag;
use nix::sys::stat;
@@ -61,7 +61,7 @@
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::slice;
use std::sync::atomic::Ordering;
use std::sync::{atomic::AtomicUsize, Arc};
use std::sync::{Arc, atomic::AtomicUsize};
/// Execute the processes specified by `j` in the parser \p.
/// On a true return, the job was successfully launched and the parser will take responsibility for
@@ -289,11 +289,7 @@ pub fn exec_subshell_for_expand(
true,
);
// Only return an error code if we should break expansion.
if break_expand {
ret
} else {
Ok(())
}
if break_expand { ret } else { Ok(()) }
}
/// Number of calls to fork() or posix_spawn().
@@ -1340,7 +1336,9 @@ fn exec_process_in_job(
}
ProcessType::Exec => {
// We should have handled exec up above.
panic!("process_type_t::exec process found in pipeline, where it should never be. Aborting.");
panic!(
"process_type_t::exec process found in pipeline, where it should never be. Aborting."
);
}
}
}

View File

@@ -8,27 +8,27 @@
STATUS_INVALID_ARGS, STATUS_NOT_EXECUTABLE, STATUS_READ_TOO_MUCH, STATUS_UNMATCHED_WILDCARD,
};
use crate::common::{
char_offset, charptr2wcstring, escape, escape_string, escape_string_for_double_quotes,
unescape_string, valid_var_name_char, wcs2zstring, EscapeFlags, EscapeStringStyle,
UnescapeFlags, UnescapeStringStyle, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END,
EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, EscapeFlags, EscapeStringStyle, UnescapeFlags,
UnescapeStringStyle, char_offset, charptr2wcstring, escape, escape_string,
escape_string_for_double_quotes, unescape_string, valid_var_name_char, wcs2zstring,
};
use crate::complete::{CompleteFlags, Completion, CompletionList, CompletionReceiver};
use crate::env::{EnvVar, Environment};
use crate::exec::exec_subshell_for_expand;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::history::{history_session_id, History};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::history::{History, history_session_id};
use crate::operation_context::OperationContext;
use crate::parse_constants::{ParseError, ParseErrorCode, ParseErrorList, SOURCE_LOCATION_UNKNOWN};
use crate::parse_util::{
parse_util_expand_variable_error, parse_util_locate_cmdsubst_range, MaybeParentheses,
MaybeParentheses, parse_util_expand_variable_error, parse_util_locate_cmdsubst_range,
};
use crate::path::path_apply_working_directory;
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};
use crate::wildcard::{WildcardResult, ANY_CHAR, ANY_STRING, ANY_STRING_RECURSIVE};
use crate::wutil::{normalize_path, wcstoi_partial, Options};
use crate::wutil::{Options, normalize_path, wcstoi_partial};
use bitflags::bitflags;
use std::mem::MaybeUninit;
@@ -1342,11 +1342,11 @@ fn stage_cmdsubst(&mut self, input: WString, out: &mut CompletionReceiver) -> Ex
}
MaybeParentheses::CommandSubstitution(parens) => {
append_cmdsub_error!(
self.errors,
parens.start(),
parens.end()-1,
"command substitutions not allowed in command position. Try var=(your-cmd) $var ..."
);
self.errors,
parens.start(),
parens.end() - 1,
"command substitutions not allowed in command position. Try var=(your-cmd) $var ..."
);
return ExpandResult::make_error(STATUS_EXPAND_ERROR);
}
}

View File

@@ -15,7 +15,7 @@
use crate::threads::assert_is_background_thread;
use crate::wutil::perror;
use errno::errno;
use libc::{c_void, EAGAIN, EINTR, EWOULDBLOCK};
use libc::{EAGAIN, EINTR, EWOULDBLOCK, c_void};
#[cfg(not(HAVE_EVENTFD))]
use crate::fds::{make_autoclose_pipes, make_fd_nonblocking};

View File

@@ -5,7 +5,7 @@
use crate::tests::prelude::*;
use crate::wchar::prelude::*;
use crate::wutil::perror;
use libc::{c_int, EINTR, FD_CLOEXEC, F_GETFD, F_GETFL, F_SETFD, F_SETFL, O_NONBLOCK};
use libc::{EINTR, F_GETFD, F_GETFL, F_SETFD, F_SETFL, FD_CLOEXEC, O_NONBLOCK, c_int};
use nix::fcntl::FcntlArg;
use nix::{fcntl::OFlag, unistd};
use std::ffi::CStr;

View File

@@ -254,7 +254,7 @@ macro_rules! should_flog {
};
}
pub use {should_flog, FLOG, FLOGF};
pub use {FLOG, FLOGF, should_flog};
/// For each category, if its name matches the wildcard, set its enabled to the given sense.
fn apply_one_wildcard(wc_esc: &wstr, sense: bool) {

View File

@@ -7,7 +7,7 @@
use crate::redirection::Dup2List;
use crate::signal::signal_reset_handlers;
use crate::{common::exit_without_destructors, wutil::fstat};
use libc::{pid_t, O_RDONLY};
use libc::{O_RDONLY, pid_t};
use std::ffi::CStr;
use std::num::NonZeroU32;
use std::os::unix::fs::MetadataExt;

View File

@@ -1,8 +1,8 @@
//! Wrappers around posix_spawn.
use super::blocked_signals_for_job;
use super::PATH_BSHELL;
use crate::exec::{is_thompson_shell_script, PgroupPolicy};
use super::blocked_signals_for_job;
use crate::exec::{PgroupPolicy, is_thompson_shell_script};
use crate::proc::Job;
use crate::redirection::Dup2List;
use crate::signal::signals_to_default;

View File

@@ -1,15 +1,15 @@
use crate::{
FLOG, FLOGF,
common::{str2wcstring, wcs2osstring, wcs2zstring},
fds::wopen_cloexec,
path::{path_remoteness, DirRemoteness},
path::{DirRemoteness, path_remoteness},
wchar::prelude::*,
wutil::{
file_id_for_file, file_id_for_path, wdirname, wrename, wunlink, FileId, INVALID_FILE_ID,
FileId, INVALID_FILE_ID, file_id_for_file, file_id_for_path, wdirname, wrename, wunlink,
},
FLOG, FLOGF,
};
use errno::errno;
use libc::{c_int, fchown, flock, LOCK_EX, LOCK_SH};
use libc::{LOCK_EX, LOCK_SH, c_int, fchown, flock};
use nix::{fcntl::OFlag, sys::stat::Mode};
use std::{
ffi::CString,
@@ -32,7 +32,7 @@ fn fish_mkstemp_cloexec(name_template: CString) -> std::io::Result<(File, CStrin
};
#[cfg(apple)]
let fd = {
use libc::{FD_CLOEXEC, F_SETFD};
use libc::{F_SETFD, FD_CLOEXEC};
let fd = unsafe { libc::mkstemp(name) };
if fd != -1 {
unsafe { libc::fcntl(fd, F_SETFD, FD_CLOEXEC) };
@@ -262,7 +262,10 @@ pub fn lock_and_load<F, UserData>(path: &wstr, load: F) -> std::io::Result<(File
// If the file id did not change, we assume that we loaded a consistent state.
return Ok((final_file_id, loaded_data));
}
Err(std::io::Error::new(std::io::ErrorKind::Other, "Failed to update the file. Locking is disabled, and the fallback code did not succeed within the permissible number of attempts."))
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Failed to update the file. Locking is disabled, and the fallback code did not succeed within the permissible number of attempts.",
))
}
pub struct PotentialUpdate<UserData> {
@@ -470,7 +473,10 @@ fn try_rewriting<F, UserData>(
// (If we did write.)
return Ok((final_file_id, potential_update));
}
Err(std::io::Error::new(std::io::ErrorKind::Other, "Failed to update the file. Locking is disabled, and the fallback code did not succeed within the permissible number of attempts."))
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Failed to update the file. Locking is disabled, and the fallback code did not succeed within the permissible number of attempts.",
))
}
const TMP_FILE_SUFFIX: &wstr = L!(".XXXXXX");

View File

@@ -4,7 +4,7 @@
use crate::ast::{self, Node};
use crate::autoload::Autoload;
use crate::common::{assert_sync, escape, valid_func_name, FilenameRef};
use crate::common::{FilenameRef, assert_sync, escape, valid_func_name};
use crate::complete::complete_wrap_map;
use crate::env::{EnvStack, Environment};
use crate::event::{self, EventDescription};

View File

@@ -20,7 +20,7 @@ fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool {
pub trait IsSorted {
type T;
fn is_sorted_by(&self, pred: impl Fn(&Self::T, &Self::T) -> Option<std::cmp::Ordering>)
-> bool;
-> bool;
}
impl<T> IsSorted for &[T] {
type T = T;

View File

@@ -1,7 +1,7 @@
use crate::flog::FLOG;
use std::cell::{Ref, RefMut};
use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
use std::sync::MutexGuard;
use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
#[derive(Debug, Default)]
pub struct RelaxedAtomicBool(AtomicBool);

View File

@@ -2,17 +2,17 @@
// to support highlighting.
// Because this may perform blocking I/O, we compute results in a separate thread,
// and provide them optimistically.
use crate::common::{unescape_string, UnescapeFlags, UnescapeStringStyle};
use crate::common::{UnescapeFlags, UnescapeStringStyle, unescape_string};
use crate::expand::{
expand_one, BRACE_BEGIN, BRACE_END, BRACE_SEP, INTERNAL_SEPARATOR, PROCESS_EXPAND_SELF,
VARIABLE_EXPAND, VARIABLE_EXPAND_SINGLE,
BRACE_BEGIN, BRACE_END, BRACE_SEP, INTERNAL_SEPARATOR, PROCESS_EXPAND_SELF, VARIABLE_EXPAND,
VARIABLE_EXPAND_SINGLE, expand_one,
};
use crate::expand::{expand_tilde, ExpandFlags, HOME_DIRECTORY};
use crate::expand::{ExpandFlags, HOME_DIRECTORY, expand_tilde};
use crate::operation_context::OperationContext;
use crate::path::path_apply_working_directory;
use crate::redirection::RedirectionMode;
use crate::threads::assert_is_background_thread;
use crate::wchar::{wstr, WString, L};
use crate::wchar::{L, WString, wstr};
use crate::wchar_ext::WExt;
use crate::wcstringutil::{
string_prefixes_string, string_prefixes_string_case_insensitive, string_suffixes_string,

View File

@@ -7,34 +7,34 @@
use crate::builtins::shared::builtin_exists;
use crate::color::Color;
use crate::common::{
valid_var_name, valid_var_name_char, ASCII_MAX, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END,
ASCII_MAX, EXPAND_RESERVED_BASE, EXPAND_RESERVED_END, valid_var_name, valid_var_name_char,
};
use crate::complete::complete_wrap_map;
use crate::env::{EnvVar, Environment};
use crate::expand::{
expand_one, expand_to_command_and_args, ExpandFlags, ExpandResultCode, PROCESS_EXPAND_SELF_STR,
ExpandFlags, ExpandResultCode, PROCESS_EXPAND_SELF_STR, expand_one, expand_to_command_and_args,
};
use crate::function;
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::highlight::file_tester::FileTester;
use crate::history::{all_paths_are_valid, HistoryItem};
use crate::history::{HistoryItem, all_paths_are_valid};
use crate::operation_context::OperationContext;
use crate::parse_constants::{
ParseKeyword, ParseTokenType, ParseTreeFlags, SourceRange, StatementDecoration,
};
use crate::parse_util::{
parse_util_locate_cmdsubst_range, parse_util_slice_length, MaybeParentheses,
MaybeParentheses, parse_util_locate_cmdsubst_range, parse_util_slice_length,
};
use crate::path::{path_as_implicit_cd, path_get_cdpath, path_get_path, paths_are_same_file};
use crate::terminal::Outputter;
use crate::text_face::{parse_text_face, TextFace, UnderlineStyle};
use crate::text_face::{TextFace, UnderlineStyle, parse_text_face};
use crate::threads::assert_is_background_thread;
use crate::tokenizer::{variable_assignment_equals_pos, PipeOrRedir};
use crate::wchar::{wstr, WString, L};
use crate::tokenizer::{PipeOrRedir, variable_assignment_equals_pos};
use crate::wchar::{L, WString, wstr};
use crate::wchar_ext::WExt;
use crate::wcstringutil::string_prefixes_string;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use super::file_tester::IsFile;

View File

@@ -7,9 +7,9 @@
use crate::wchar::prelude::*;
use crate::{
env::EnvStack,
highlight::file_tester::{is_potential_path, PathFlags},
highlight::{highlight_shell, HighlightRole, HighlightSpec},
operation_context::{OperationContext, EXPANSION_LIMIT_BACKGROUND, EXPANSION_LIMIT_DEFAULT},
highlight::file_tester::{PathFlags, is_potential_path},
highlight::{HighlightRole, HighlightSpec, highlight_shell},
operation_context::{EXPANSION_LIMIT_BACKGROUND, EXPANSION_LIMIT_DEFAULT, OperationContext},
};
use libc::PATH_MAX;
@@ -722,7 +722,7 @@ mod file_tester_tests {
use super::*;
use crate::common::charptr2wcstring;
use crate::redirection::RedirectionMode;
use std::fs::{self, create_dir_all, File, Permissions};
use std::fs::{self, File, Permissions, create_dir_all};
use std::os::unix::fs::PermissionsExt;
struct TempDir {

View File

@@ -18,8 +18,8 @@
common::cstr2wcstring,
env::EnvVar,
fs::{
lock_and_load, rewrite_via_temporary_file, LockedFile, LockingMode, PotentialUpdate,
WriteMethod, LOCKED_FILE_MODE,
LOCKED_FILE_MODE, LockedFile, LockingMode, PotentialUpdate, WriteMethod, lock_and_load,
rewrite_via_temporary_file,
},
wcstringutil::trim,
};
@@ -43,15 +43,15 @@
use crate::{
ast::{self, Kind, Node},
common::{str2wcstring, unescape_string, valid_var_name, CancelChecker, UnescapeStringStyle},
common::{CancelChecker, UnescapeStringStyle, str2wcstring, unescape_string, valid_var_name},
env::{EnvMode, EnvStack, Environment},
expand::{expand_one, ExpandFlags},
expand::{ExpandFlags, expand_one},
fds::wopen_cloexec,
flog::{FLOG, FLOGF},
fs::fsync,
history::file::{append_history_item_to_buffer, HistoryFileContents},
history::file::{HistoryFileContents, append_history_item_to_buffer},
io::IoStreams,
operation_context::{OperationContext, EXPANSION_LIMIT_BACKGROUND},
operation_context::{EXPANSION_LIMIT_BACKGROUND, OperationContext},
parse_constants::{ParseTreeFlags, StatementDecoration},
parse_util::{parse_util_detect_errors, parse_util_unescape_wildcards},
path::{path_get_config, path_get_data, path_is_valid},
@@ -59,8 +59,8 @@
util::{find_subslice, get_rng},
wchar::prelude::*,
wcstringutil::subsequence_in_string,
wildcard::{wildcard_match, ANY_STRING},
wutil::{file_id_for_file, wgettext_fmt, wrealpath, wstat, wunlink, FileId, INVALID_FILE_ID},
wildcard::{ANY_STRING, wildcard_match},
wutil::{FileId, INVALID_FILE_ID, file_id_for_file, wgettext_fmt, wrealpath, wstat, wunlink},
};
mod file;
@@ -370,7 +370,10 @@ fn history_file_path(&self) -> std::io::Result<Option<WString>> {
}
let Some(mut path) = path_get_data() else {
return Err(std::io::Error::new(std::io::ErrorKind::NotFound, "Error obtaining data directory. This is a manually constructed error which does not indicate why this happened."));
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Error obtaining data directory. This is a manually constructed error which does not indicate why this happened.",
));
};
path.push('/');

View File

@@ -9,13 +9,13 @@
time::{Duration, SystemTime, UNIX_EPOCH},
};
use libc::{mmap, munmap, ENODEV, MAP_ANONYMOUS, MAP_FAILED, MAP_PRIVATE, PROT_READ, PROT_WRITE};
use libc::{ENODEV, MAP_ANONYMOUS, MAP_FAILED, MAP_PRIVATE, PROT_READ, PROT_WRITE, mmap, munmap};
use super::{HistoryItem, PersistenceMode};
use crate::{
common::{str2wcstring, subslice_position, wcs2string},
flog::FLOG,
path::{path_get_data_remoteness, DirRemoteness},
path::{DirRemoteness, path_get_data_remoteness},
};
/// History file types.
@@ -125,7 +125,7 @@ pub fn create(mut history_file: &File) -> std::io::Result<Self> {
return Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
format!("Cannot convert u64 to usize: {err}"),
))
));
}
};
if len == 0 {

View File

@@ -1,4 +1,4 @@
use crate::common::{escape, get_by_sorted_name, str2wcstring, Named};
use crate::common::{Named, escape, get_by_sorted_name, str2wcstring};
use crate::env::Environment;
use crate::event;
use crate::flog::FLOG;
@@ -7,13 +7,13 @@
use crate::future::IsSomeAnd;
use crate::global_safety::RelaxedAtomicBool;
use crate::input_common::{
match_key_event_to_key, CharEvent, CharInputStyle, ImplicitEvent, InputData, InputEventQueuer,
KeyMatchQuality, ReadlineCmd, R_END_INPUT_FUNCTIONS,
CharEvent, CharInputStyle, ImplicitEvent, InputData, InputEventQueuer, KeyMatchQuality,
R_END_INPUT_FUNCTIONS, ReadlineCmd, match_key_event_to_key,
};
use crate::key::{self, canonicalize_raw_escapes, ctrl, Key, Modifiers};
use crate::key::{self, Key, Modifiers, canonicalize_raw_escapes, ctrl};
use crate::proc::job_reap;
use crate::reader::{
reader_reading_interrupted, reader_reset_interrupted, reader_schedule_prompt_repaint, Reader,
Reader, reader_reading_interrupted, reader_reset_interrupted, reader_schedule_prompt_repaint,
};
use crate::signal::signal_clear_cancel;
use crate::threads::{assert_is_main_thread, iothread_service_main};
@@ -21,8 +21,8 @@
use once_cell::sync::Lazy;
use std::mem;
use std::sync::{
atomic::{AtomicU32, Ordering},
Mutex, MutexGuard,
atomic::{AtomicU32, Ordering},
};
pub const FISH_BIND_MODE_VAR: &wstr = L!("fish_bind_mode");

View File

@@ -1,19 +1,19 @@
use crate::common::{
fish_reserved_codepoint, get_is_multibyte_locale, is_windows_subsystem_for_linux, read_blocked,
shell_modes, str2wcstring, WSL,
WSL, fish_reserved_codepoint, get_is_multibyte_locale, is_windows_subsystem_for_linux,
read_blocked, shell_modes, str2wcstring,
};
use crate::env::{EnvStack, Environment};
use crate::fd_readable_set::{FdReadableSet, Timeout};
use crate::flog::{FloggableDebug, FloggableDisplay, FLOG};
use crate::flog::{FLOG, FloggableDebug, FloggableDisplay};
use crate::key::{
self, alt, canonicalize_control_char, canonicalize_keyed_control_char, char_to_symbol,
function_key, shift, Key, Modifiers, ViewportPosition,
self, Key, Modifiers, ViewportPosition, alt, canonicalize_control_char,
canonicalize_keyed_control_char, char_to_symbol, function_key, shift,
};
use crate::reader::reader_test_and_clear_interrupted;
use crate::threads::iothread_port;
use crate::tty_handoff::{
maybe_set_kitty_keyboard_capability, maybe_set_scroll_content_up_capability,
SCROLL_CONTENT_UP_TERMINFO_CODE, XTVERSION,
SCROLL_CONTENT_UP_TERMINFO_CODE, XTVERSION, maybe_set_kitty_keyboard_capability,
maybe_set_scroll_content_up_capability,
};
use crate::universal_notifier::default_notifier;
use crate::wchar::{encode_byte_to_char, prelude::*};

View File

@@ -1,10 +1,10 @@
use crate::builtins::shared::{STATUS_CMD_ERROR, STATUS_CMD_OK, STATUS_READ_TOO_MUCH};
use crate::common::{str2wcstring, wcs2string, EMPTY_STRING};
use crate::common::{EMPTY_STRING, str2wcstring, wcs2string};
use crate::fd_monitor::{Callback, FdMonitor, FdMonitorItemId};
use crate::fds::{
make_autoclose_pipes, make_fd_nonblocking, wopen_cloexec, AutoCloseFd, PIPE_ERROR,
AutoCloseFd, PIPE_ERROR, make_autoclose_pipes, make_fd_nonblocking, wopen_cloexec,
};
use crate::flog::{should_flog, FLOG, FLOGF};
use crate::flog::{FLOG, FLOGF, should_flog};
use crate::nix::isatty;
use crate::path::path_apply_working_directory;
use crate::proc::JobGroupRef;

View File

@@ -1,10 +1,10 @@
use libc::VERASE;
use crate::{
common::{escape_string, EscapeFlags, EscapeStringStyle},
common::{EscapeFlags, EscapeStringStyle, escape_string},
fallback::fish_wcwidth,
flog::FloggableDebug,
future_feature_flags::{test as feature_test, FeatureFlag},
future_feature_flags::{FeatureFlag, test as feature_test},
reader::safe_get_terminal_mode_on_startup,
wchar::{decode_byte_from_char, prelude::*},
wutil::fish_wcstoul,
@@ -285,7 +285,7 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
"unknown modifier '%s' in '%s'",
modifier,
escape_nonprintables(full_key_name)
))
));
}
}
}

View File

@@ -1,5 +1,5 @@
/// Support for the "current locale."
pub use fish_printf::locale::{Locale, C_LOCALE};
pub use fish_printf::locale::{C_LOCALE, Locale};
use std::sync::Mutex;
/// Lock guarding libc `setlocale()` or `localeconv()` calls to avoid races.

View File

@@ -1,5 +1,5 @@
use crate::common::{assert_send, assert_sync};
use std::ffi::{c_char, CStr, CString};
use std::ffi::{CStr, CString, c_char};
use std::marker::PhantomData;
use std::pin::Pin;
use std::ptr;

View File

@@ -1,19 +1,19 @@
//! Pager support.
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use crate::common::{
escape_string, get_ellipsis_char, get_ellipsis_str, get_is_multibyte_locale, EscapeFlags,
EscapeStringStyle,
EscapeFlags, EscapeStringStyle, escape_string, get_ellipsis_char, get_ellipsis_str,
get_is_multibyte_locale,
};
use crate::complete::Completion;
use crate::editable_line::EditableLine;
#[allow(unused_imports)]
use crate::future::IsSomeAnd;
use crate::highlight::{highlight_shell, HighlightRole, HighlightSpec};
use crate::highlight::{HighlightRole, HighlightSpec, highlight_shell};
use crate::operation_context::OperationContext;
use crate::screen::{wcswidth_rendered, wcwidth_rendered, CharOffset, Line, ScreenData};
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;

View File

@@ -1,5 +1,5 @@
use std::{
panic::{set_hook, take_hook, UnwindSafe},
panic::{UnwindSafe, set_hook, take_hook},
sync::atomic::{AtomicBool, Ordering},
time::Duration,
};
@@ -8,7 +8,7 @@
use once_cell::sync::OnceCell;
use crate::{
common::{read_blocked, PROGRAM_NAME},
common::{PROGRAM_NAME, read_blocked},
nix::isatty,
threads::{asan_maybe_exit, is_main_thread},
};

View File

@@ -1,24 +1,24 @@
//! Provides the "linkage" between an ast and actual execution structures (job_t, etc.).
use crate::ast::{
self, unescape_keyword, BlockStatementHeader, Keyword, Leaf, Node, Statement, Token,
self, BlockStatementHeader, Keyword, Leaf, Node, Statement, Token, unescape_keyword,
};
use crate::builtins;
use crate::builtins::shared::{
builtin_exists, BUILTIN_ERR_VARNAME, STATUS_CMD_ERROR, STATUS_CMD_OK, STATUS_CMD_UNKNOWN,
STATUS_EXPAND_ERROR, STATUS_ILLEGAL_CMD, STATUS_INVALID_ARGS, STATUS_NOT_EXECUTABLE,
STATUS_UNMATCHED_WILDCARD,
BUILTIN_ERR_VARNAME, STATUS_CMD_ERROR, STATUS_CMD_OK, STATUS_CMD_UNKNOWN, STATUS_EXPAND_ERROR,
STATUS_ILLEGAL_CMD, STATUS_INVALID_ARGS, STATUS_NOT_EXECUTABLE, STATUS_UNMATCHED_WILDCARD,
builtin_exists,
};
use crate::common::{
escape, should_suppress_stderr_for_tests, truncate_at_nul, valid_var_name, ScopeGuard,
ScopeGuarding, ScopedRefCell,
ScopeGuard, ScopeGuarding, ScopedRefCell, escape, should_suppress_stderr_for_tests,
truncate_at_nul, valid_var_name,
};
use crate::complete::CompletionList;
use crate::env::{EnvMode, EnvStackSetResult, EnvVar, EnvVarFlags, Environment, Statuses};
use crate::event::{self, Event};
use crate::exec::exec_job;
use crate::expand::{
expand_one, expand_string, expand_to_command_and_args, ExpandFlags, ExpandResultCode,
ExpandFlags, ExpandResultCode, expand_one, expand_string, expand_to_command_and_args,
};
use crate::flog::FLOG;
use crate::function;
@@ -26,33 +26,33 @@
use crate::job_group::JobGroup;
use crate::operation_context::OperationContext;
use crate::parse_constants::{
parse_error_offset_source_start, ParseError, ParseErrorCode, ParseErrorList, ParseKeyword,
ParseTokenType, StatementDecoration, CALL_STACK_LIMIT_EXCEEDED_ERR_MSG, ERROR_TIME_BACKGROUND,
CALL_STACK_LIMIT_EXCEEDED_ERR_MSG, ERROR_TIME_BACKGROUND,
FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG, ILLEGAL_FD_ERR_MSG, INFINITE_FUNC_RECURSION_ERR_MSG,
WILDCARD_ERR_MSG,
ParseError, ParseErrorCode, ParseErrorList, ParseKeyword, ParseTokenType, StatementDecoration,
WILDCARD_ERR_MSG, parse_error_offset_source_start,
};
use crate::parse_tree::{LineCounter, NodeRef, ParsedSourceRef};
use crate::parse_util::{
parse_util_locate_cmdsubst_range, parse_util_unescape_wildcards,
MaybeParentheses::CommandSubstitution,
MaybeParentheses::CommandSubstitution, parse_util_locate_cmdsubst_range,
parse_util_unescape_wildcards,
};
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::proc::{
get_job_control_mode, job_reap, no_exec, ConcreteAssignment, Job, JobControl, JobProperties,
JobRef, Process, ProcessType,
ConcreteAssignment, Job, JobControl, JobProperties, JobRef, Process, ProcessType,
get_job_control_mode, job_reap, no_exec,
};
use crate::reader::fish_is_unwinding_for_exit;
use crate::redirection::{RedirectionMode, RedirectionSpec, RedirectionSpecList};
use crate::signal::Signal;
use crate::timer::push_timer;
use crate::tokenizer::{variable_assignment_equals_pos, PipeOrRedir, TokenType};
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::wchar_ext::WExt;
use crate::wildcard::wildcard_match;
use libc::{c_int, ENOTDIR, EXIT_SUCCESS, STDERR_FILENO, STDOUT_FILENO};
use libc::{ENOTDIR, EXIT_SUCCESS, STDERR_FILENO, STDOUT_FILENO, c_int};
use std::io::ErrorKind;
use std::rc::Rc;
use std::sync::Arc;
@@ -421,11 +421,7 @@ fn infinite_recursive_statement_in_job_list<'b>(
None,
)
&& &cmd == forbidden_function_name;
if forbidden {
Some(dc)
} else {
None
}
if forbidden { Some(dc) } else { None }
};
// Check main statement.
@@ -1464,7 +1460,9 @@ fn determine_redirections(
_ => false,
}
} {
eprintf!("If you wish to use process substitution, consider the psub command, see: `help psub`\n");
eprintf!(
"If you wish to use process substitution, consider the psub command, see: `help psub`\n"
);
}
return error_ret;
}

View File

@@ -7,8 +7,8 @@
use crate::ast::{self, Ast, JobList, Node};
use crate::common::{assert_send, assert_sync};
use crate::parse_constants::{
token_type_user_presentable_description, ParseErrorCode, ParseErrorList, ParseKeyword,
ParseTokenType, ParseTreeFlags, SourceOffset, SourceRange, SOURCE_OFFSET_INVALID,
ParseErrorCode, ParseErrorList, ParseKeyword, ParseTokenType, ParseTreeFlags,
SOURCE_OFFSET_INVALID, SourceOffset, SourceRange, token_type_user_presentable_description,
};
use crate::tokenizer::TokenizerError;
use crate::wchar::prelude::*;

View File

@@ -1,29 +1,30 @@
//! Various mostly unrelated utility functions related to parsing, loading and evaluating fish code.
use crate::ast::{
self, is_same_node, Ast, Keyword, Kind, Leaf, Node, NodeVisitor, Token, Traversal,
self, Ast, Keyword, Kind, Leaf, Node, NodeVisitor, Token, Traversal, is_same_node,
};
use crate::builtins::shared::builtin_exists;
use crate::common::{
escape_string, unescape_string, valid_var_name, valid_var_name_char, EscapeFlags,
EscapeStringStyle, UnescapeFlags, UnescapeStringStyle,
EscapeFlags, EscapeStringStyle, UnescapeFlags, UnescapeStringStyle, escape_string,
unescape_string, valid_var_name, valid_var_name_char,
};
use crate::expand::{
expand_one, expand_to_command_and_args, ExpandFlags, ExpandResultCode, BRACE_BEGIN, BRACE_END,
BRACE_SEP, INTERNAL_SEPARATOR, VARIABLE_EXPAND, VARIABLE_EXPAND_EMPTY, VARIABLE_EXPAND_SINGLE,
BRACE_BEGIN, BRACE_END, BRACE_SEP, ExpandFlags, ExpandResultCode, INTERNAL_SEPARATOR,
VARIABLE_EXPAND, VARIABLE_EXPAND_EMPTY, VARIABLE_EXPAND_SINGLE, expand_one,
expand_to_command_and_args,
};
use crate::future_feature_flags::{feature_test, FeatureFlag};
use crate::future_feature_flags::{FeatureFlag, feature_test};
use crate::operation_context::OperationContext;
use crate::parse_constants::{
parse_error_offset_source_start, ParseError, ParseErrorCode, ParseErrorList, ParseKeyword,
ERROR_BAD_VAR_CHAR1, ERROR_BRACKETED_VARIABLE_QUOTED1, ERROR_BRACKETED_VARIABLE1,
ERROR_NO_VAR_NAME, ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR, ERROR_NOT_PID,
ERROR_NOT_STATUS, INVALID_BREAK_ERR_MSG, INVALID_CONTINUE_ERR_MSG,
INVALID_PIPELINE_CMD_ERR_MSG, ParseError, ParseErrorCode, ParseErrorList, ParseKeyword,
ParseTokenType, ParseTreeFlags, ParserTestErrorBits, PipelinePosition, SourceRange,
StatementDecoration, ERROR_BAD_VAR_CHAR1, ERROR_BRACKETED_VARIABLE1,
ERROR_BRACKETED_VARIABLE_QUOTED1, ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR,
ERROR_NOT_PID, ERROR_NOT_STATUS, ERROR_NO_VAR_NAME, INVALID_BREAK_ERR_MSG,
INVALID_CONTINUE_ERR_MSG, INVALID_PIPELINE_CMD_ERR_MSG, UNKNOWN_BUILTIN_ERR_MSG,
StatementDecoration, UNKNOWN_BUILTIN_ERR_MSG, parse_error_offset_source_start,
};
use crate::tokenizer::{
comment_end, is_token_delimiter, quote_end, Tok, TokenType, Tokenizer, TOK_ACCEPT_UNFINISHED,
TOK_SHOW_COMMENTS,
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;
@@ -1512,11 +1513,7 @@ pub fn parse_util_detect_errors_in_argument(
err |= check_subtoken(checked, arg_src.len(), out_errors);
if err.is_empty() {
Ok(())
} else {
Err(err)
}
if err.is_empty() { Ok(()) } else { Err(err) }
}
fn detect_errors_in_job_conjunction(

View File

@@ -3,36 +3,36 @@
use crate::ast::{self, Node};
use crate::builtins::shared::STATUS_ILLEGAL_CMD;
use crate::common::{
escape_string, wcs2string, CancelChecker, EscapeFlags, EscapeStringStyle, FilenameRef,
ScopeGuarding, ScopedCell, ScopedRefCell, PROFILING_ACTIVE,
CancelChecker, EscapeFlags, EscapeStringStyle, FilenameRef, PROFILING_ACTIVE, ScopeGuarding,
ScopedCell, ScopedRefCell, escape_string, wcs2string,
};
use crate::complete::CompletionList;
use crate::env::{EnvMode, EnvStack, EnvStackSetResult, Environment, Statuses};
use crate::event::{self, Event};
use crate::expand::{
expand_string, replace_home_directory_with_tilde, ExpandFlags, ExpandResultCode,
ExpandFlags, ExpandResultCode, expand_string, replace_home_directory_with_tilde,
};
use crate::fds::{open_dir, BEST_O_SEARCH};
use crate::fds::{BEST_O_SEARCH, open_dir};
use crate::global_safety::RelaxedAtomicBool;
use crate::input_common::TerminalQuery;
use crate::io::IoChain;
use crate::job_group::MaybeJobId;
use crate::operation_context::{OperationContext, EXPANSION_LIMIT_DEFAULT};
use crate::operation_context::{EXPANSION_LIMIT_DEFAULT, OperationContext};
use crate::parse_constants::{
ParseError, ParseErrorList, ParseTreeFlags, FISH_MAX_EVAL_DEPTH, FISH_MAX_STACK_DEPTH,
FISH_MAX_EVAL_DEPTH, FISH_MAX_STACK_DEPTH, ParseError, ParseErrorList, ParseTreeFlags,
SOURCE_LOCATION_UNKNOWN,
};
use crate::parse_execution::{EndExecutionReason, ExecutionContext};
use crate::parse_tree::NodeRef;
use crate::parse_tree::{parse_source, LineCounter, ParsedSourceRef};
use crate::proc::{job_reap, JobGroupRef, JobList, JobRef, Pid, ProcStatus};
use crate::signal::{signal_check_cancel, signal_clear_cancel, Signal};
use crate::parse_tree::{LineCounter, ParsedSourceRef, parse_source};
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::wchar_ext::WExt;
use crate::wutil::perror;
use crate::{function, FLOG};
use crate::{FLOG, function};
use libc::c_int;
#[cfg(not(target_has_atomic = "64"))]
use portable_atomic::AtomicU64;
@@ -43,9 +43,9 @@
use std::num::NonZeroU32;
use std::os::fd::OwnedFd;
use std::rc::Rc;
use std::sync::Arc;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::Arc;
use std::time::Duration;
pub enum BlockData {

View File

@@ -4,11 +4,11 @@
use crate::common::{wcs2osstring, wcs2zstring};
use crate::env::{EnvMode, EnvStack, Environment, FALLBACK_PATH};
use crate::expand::{expand_tilde, HOME_DIRECTORY};
use crate::expand::{HOME_DIRECTORY, expand_tilde};
use crate::flog::{FLOG, FLOGF};
use crate::wchar::prelude::*;
use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wstat};
use errno::{errno, set_errno, Errno};
use errno::{Errno, errno, set_errno};
use libc::{EACCES, ENOENT, ENOTDIR, F_OK, X_OK};
use once_cell::sync::Lazy;
use std::ffi::OsStr;
@@ -585,7 +585,7 @@ fn make_base_directory(xdg_var: &wstr, non_xdg_homepath: &wstr) -> BaseDirectory
// the actual $HOME or $XDG_XXX directories. This prevents the tests from failing and/or stops
// the tests polluting the user's actual $HOME if a sandbox environment has not been set up.
{
use crate::common::{str2wcstring, BUILD_DIR};
use crate::common::{BUILD_DIR, str2wcstring};
use std::path::PathBuf;
let mut build_dir = PathBuf::from(BUILD_DIR);

View File

@@ -4,7 +4,7 @@
use crate::ast;
use crate::common::{
charptr2wcstring, escape, is_windows_subsystem_for_linux, timef, Timepoint, WSL,
Timepoint, WSL, charptr2wcstring, escape, is_windows_subsystem_for_linux, timef,
};
use crate::env::Statuses;
use crate::event::{self, Event};
@@ -16,16 +16,16 @@
use crate::parser::{Block, Parser};
use crate::reader::{fish_is_unwinding_for_exit, reader_schedule_prompt_repaint};
use crate::redirection::RedirectionSpecList;
use crate::signal::{signal_set_handlers_once, Signal};
use crate::topic_monitor::{topic_monitor_principal, GenerationsList, Topic};
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::wchar_ext::ToWString;
use crate::wutil::{wbasename, wperror};
use libc::{
EXIT_SUCCESS, SIGABRT, SIGBUS, SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE,
SIGQUIT, SIGSEGV, SIGSYS, SIGTTOU, SIG_DFL, SIG_IGN, WCONTINUED, WEXITSTATUS, WIFCONTINUED,
WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WTERMSIG, WUNTRACED, _SC_CLK_TCK,
_SC_CLK_TCK, EXIT_SUCCESS, SIG_DFL, SIG_IGN, SIGABRT, SIGBUS, SIGCONT, SIGFPE, SIGHUP, SIGILL,
SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGSYS, SIGTTOU, WCONTINUED, WEXITSTATUS,
WIFCONTINUED, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WTERMSIG, WUNTRACED,
};
use once_cell::sync::Lazy;
#[cfg(not(target_has_atomic = "64"))]
@@ -891,11 +891,7 @@ pub fn get_statuses(&self) -> Option<Statuses> {
return None;
}
st.status = if self.flags().negate {
if laststatus == 0 {
1
} else {
0
}
if laststatus == 0 { 1 } else { 0 }
} else {
laststatus
};

View File

@@ -18,9 +18,9 @@
//! expansion, etc.
use libc::{
c_char, ECHO, EINTR, EIO, EISDIR, ENOTTY, EPERM, ESRCH, ICANON, ICRNL, IEXTEN, INLCR, IXOFF,
IXON, ONLCR, OPOST, O_NONBLOCK, O_RDONLY, SIGINT, SIGTTIN, STDERR_FILENO, STDIN_FILENO,
STDOUT_FILENO, TCSANOW, VMIN, VQUIT, VSUSP, VTIME, _POSIX_VDISABLE,
_POSIX_VDISABLE, ECHO, EINTR, EIO, EISDIR, ENOTTY, EPERM, ESRCH, ICANON, ICRNL, IEXTEN, INLCR,
IXOFF, IXON, O_NONBLOCK, O_RDONLY, ONLCR, OPOST, SIGINT, SIGTTIN, STDERR_FILENO, STDIN_FILENO,
STDOUT_FILENO, TCSANOW, VMIN, VQUIT, VSUSP, VTIME, c_char,
};
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
@@ -41,39 +41,39 @@
use std::rc::Rc;
#[cfg(target_has_atomic = "64")]
use std::sync::atomic::AtomicU64;
use std::sync::atomic::{AtomicI32, AtomicU32, AtomicU8, Ordering};
use std::sync::atomic::{AtomicI32, AtomicU8, AtomicU32, Ordering};
use std::sync::{Arc, Mutex, MutexGuard};
use std::time::{Duration, Instant};
use errno::{errno, Errno};
use errno::{Errno, errno};
use crate::abbrs::abbrs_match;
use crate::ast::{self, is_same_node, Kind};
use crate::ast::{self, Kind, is_same_node};
use crate::builtins::shared::ErrorCode;
use crate::builtins::shared::STATUS_CMD_ERROR;
use crate::builtins::shared::STATUS_CMD_OK;
use crate::common::ScopeGuarding;
use crate::common::{
escape, escape_string, exit_without_destructors, get_ellipsis_char, get_is_multibyte_locale,
EscapeFlags, EscapeStringStyle, PROGRAM_NAME, ScopeGuard, UTF8_BOM_WCHAR, escape,
escape_string, exit_without_destructors, get_ellipsis_char, get_is_multibyte_locale,
get_obfuscation_read_char, restore_term_foreground_process_group_for_exit, shell_modes,
str2wcstring, write_loop, EscapeFlags, EscapeStringStyle, ScopeGuard, PROGRAM_NAME,
UTF8_BOM_WCHAR,
str2wcstring, write_loop,
};
use crate::complete::{
complete, complete_load, sort_and_prioritize, CompleteFlags, Completion, CompletionList,
CompletionRequestOptions,
CompleteFlags, Completion, CompletionList, CompletionRequestOptions, complete, complete_load,
sort_and_prioritize,
};
use crate::editable_line::{line_at_cursor, range_of_line_at_cursor, Edit, EditableLine};
use crate::editable_line::{Edit, EditableLine, line_at_cursor, range_of_line_at_cursor};
use crate::env::EnvStack;
use crate::env::{EnvMode, Environment, Statuses};
use crate::env_dispatch::guess_emoji_width;
use crate::env_dispatch::MIDNIGHT_COMMANDER_SID;
use crate::env_dispatch::guess_emoji_width;
use crate::exec::exec_subshell;
use crate::expand::expand_one;
use crate::expand::{expand_string, expand_tilde, ExpandFlags, ExpandResultCode};
use crate::expand::{ExpandFlags, ExpandResultCode, expand_string, expand_tilde};
use crate::fallback::fish_wcwidth;
use crate::fd_readable_set::poll_fd_readable;
use crate::fds::{make_fd_blocking, wopen_cloexec, AutoCloseFd};
use crate::fds::{AutoCloseFd, make_fd_blocking, wopen_cloexec};
use crate::flog::{FLOG, FLOGF};
#[allow(unused_imports)]
use crate::future::IsSomeAnd;
@@ -81,32 +81,32 @@
use crate::future_feature_flags::FeatureFlag;
use crate::global_safety::RelaxedAtomicBool;
use crate::highlight::{
autosuggest_validate_from_history, highlight_shell, parse_text_face_for_highlight,
HighlightRole, HighlightSpec,
HighlightRole, HighlightSpec, autosuggest_validate_from_history, highlight_shell,
parse_text_face_for_highlight,
};
use crate::history::{
history_session_id, in_private_mode, History, HistorySearch, PersistenceMode, SearchDirection,
SearchFlags, SearchType,
History, HistorySearch, PersistenceMode, SearchDirection, SearchFlags, SearchType,
history_session_id, in_private_mode,
};
use crate::input_common::InputEventQueue;
use crate::input_common::InputEventQueuer;
use crate::input_common::QueryResponse;
use crate::input_common::{
stop_query, CharEvent, CharInputStyle, CursorPositionQuery, CursorPositionQueryKind,
ImplicitEvent, InputData, QueryResultEvent, ReadlineCmd, TerminalQuery,
CharEvent, CharInputStyle, CursorPositionQuery, CursorPositionQueryKind, ImplicitEvent,
InputData, QueryResultEvent, ReadlineCmd, TerminalQuery, stop_query,
};
use crate::io::IoChain;
use crate::key::ViewportPosition;
use crate::kill::{kill_add, kill_replace, kill_yank, kill_yank_rotate};
use crate::nix::{getpgrp, getpid, isatty};
use crate::operation_context::{get_bg_context, OperationContext};
use crate::operation_context::{OperationContext, get_bg_context};
use crate::pager::{PageRendering, Pager, SelectionMotion};
use crate::panic::AT_EXIT;
use crate::parse_constants::SourceRange;
use crate::parse_constants::{ParseTreeFlags, ParserTestErrorBits};
use crate::parse_util::parse_util_process_extent;
use crate::parse_util::MaybeParentheses;
use crate::parse_util::SPACES_PER_INDENT;
use crate::parse_util::parse_util_process_extent;
use crate::parse_util::{
parse_util_cmdsubst_extent, parse_util_compute_indents, parse_util_contains_wildcards,
parse_util_detect_errors, parse_util_escape_string_with_quote, parse_util_escape_wildcards,
@@ -118,9 +118,9 @@
have_proc_stat, hup_jobs, is_interactive_session, job_reap, jobs_requiring_warning_on_exit,
print_exit_warning_for_jobs, proc_update_jiffies,
};
use crate::reader_history_search::{smartcase_flags, ReaderHistorySearch, SearchMode};
use crate::reader_history_search::{ReaderHistorySearch, SearchMode, smartcase_flags};
use crate::screen::is_dumb;
use crate::screen::{screen_force_clear_to_end, CharOffset, Screen};
use crate::screen::{CharOffset, Screen, screen_force_clear_to_end};
use crate::should_flog;
use crate::signal::{
signal_check_cancel, signal_clear_cancel, signal_reset_handlers, signal_set_handlers,
@@ -136,28 +136,28 @@
QueryXtgettcap, QueryXtversion,
};
use crate::termsize::{termsize_invalidate_tty, termsize_last, termsize_update};
use crate::text_face::parse_text_face;
use crate::text_face::TextFace;
use crate::text_face::parse_text_face;
use crate::threads::{
assert_is_background_thread, assert_is_main_thread, iothread_service_main_with_timeout,
Debounce,
Debounce, assert_is_background_thread, assert_is_main_thread,
iothread_service_main_with_timeout,
};
use crate::tokenizer::quote_end;
use crate::tokenizer::variable_assignment_equals_pos;
use crate::tokenizer::{
tok_command, MoveWordStateMachine, MoveWordStyle, TokenType, Tokenizer, TOK_ACCEPT_UNFINISHED,
TOK_SHOW_COMMENTS,
MoveWordStateMachine, MoveWordStyle, TOK_ACCEPT_UNFINISHED, TOK_SHOW_COMMENTS, TokenType,
Tokenizer, tok_command,
};
use crate::tty_handoff::SCROLL_CONTENT_UP_TERMINFO_CODE;
use crate::tty_handoff::{
get_tty_protocols_active, initialize_tty_protocols, safe_deactivate_tty_protocols, TtyHandoff,
TtyHandoff, get_tty_protocols_active, initialize_tty_protocols, safe_deactivate_tty_protocols,
};
use crate::wchar::prelude::*;
use crate::wcstringutil::string_prefixes_string_maybe_case_insensitive;
use crate::wcstringutil::CaseSensitivity;
use crate::wcstringutil::string_prefixes_string_maybe_case_insensitive;
use crate::wcstringutil::{
count_preceding_backslashes, join_strings, string_prefixes_string,
string_prefixes_string_case_insensitive, StringFuzzyMatch,
StringFuzzyMatch, count_preceding_backslashes, join_strings, string_prefixes_string,
string_prefixes_string_case_insensitive,
};
use crate::wildcard::wildcard_has;
use crate::wutil::{fstat, perror, write_to_fd, wstat};
@@ -318,9 +318,9 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue
See 'help terminal-compatibility' or 'man fish-terminal-compatibility'. \
This %s process will no longer wait for outstanding queries, \
which disables some optional features.",
program,
INITIAL_QUERY_TIMEOUT_SECONDS,
program
program,
INITIAL_QUERY_TIMEOUT_SECONDS,
program
),
);
input_queue
@@ -2537,17 +2537,19 @@ fn handle_char_event(&mut self, injected_event: Option<CharEvent>) -> ControlFlo
return ControlFlow::Break(());
}
let event_needing_handling = injected_event.or_else(|| loop {
let event_needing_handling = self.read_normal_chars();
if event_needing_handling.is_some() {
break event_needing_handling;
}
if self
.rls()
.nchars
.is_some_and(|nchars| usize::from(nchars) <= self.command_line_len())
{
break None;
let event_needing_handling = injected_event.or_else(|| {
loop {
let event_needing_handling = self.read_normal_chars();
if event_needing_handling.is_some() {
break event_needing_handling;
}
if self
.rls()
.nchars
.is_some_and(|nchars| usize::from(nchars) <= self.command_line_len())
{
break None;
}
}
});
@@ -4559,7 +4561,13 @@ fn acquire_tty_or_exit(shell_pgid: libc::pid_t) {
if check_for_orphaned_process(loop_count, shell_pgid) {
// We're orphaned, so we just die. Another sad statistic.
let pid = getpid();
FLOG!(warning, sprintf!("I appear to be an orphaned process, so I am quitting politely. My pid is %d.", pid));
FLOG!(
warning,
sprintf!(
"I appear to be an orphaned process, so I am quitting politely. My pid is %d.",
pid
)
);
exit_without_destructors(1);
}

View File

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

View File

@@ -7,16 +7,16 @@
//! The current implementation is less smart than ncurses allows and can not for example move blocks
//! of text around to handle text insertion.
use crate::FLOG;
use crate::editable_line::line_at_cursor;
use crate::key::ViewportPosition;
use crate::pager::{PageRendering, Pager, PAGER_MIN_HEIGHT};
use crate::FLOG;
use crate::pager::{PAGER_MIN_HEIGHT, PageRendering, Pager};
use std::cell::RefCell;
use std::collections::LinkedList;
use std::io::Write;
use std::ops::Range;
use std::sync::atomic::AtomicU32;
use std::sync::Mutex;
use std::sync::atomic::AtomicU32;
use std::time::SystemTime;
use libc::{ONLCR, STDERR_FILENO, STDOUT_FILENO};
@@ -36,8 +36,8 @@
self, ClearToEndOfLine, ClearToEndOfScreen, CursorDown, CursorLeft, CursorMove, CursorRight,
CursorUp, EnterDimMode, ExitAttributeMode, Osc133PromptStart, ScrollContentUp,
};
use crate::terminal::{use_terminfo, BufferedOutputter, CardinalDirection, Output, Outputter};
use crate::termsize::{termsize_last, Termsize};
use crate::terminal::{BufferedOutputter, CardinalDirection, Output, Outputter, use_terminfo};
use crate::termsize::{Termsize, termsize_last};
use crate::wchar::prelude::*;
use crate::wcstringutil::{fish_wcwidth_visible, string_prefixes_string};
use crate::wutil::fstat;

View File

@@ -6,7 +6,7 @@
use crate::nix::getpid;
use crate::reader::{reader_handle_sigint, reader_sighup, safe_restore_term_mode};
use crate::termsize::TermsizeContainer;
use crate::topic_monitor::{topic_monitor_principal, Generation, GenerationsList, Topic};
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};

View File

@@ -1,13 +1,13 @@
// Generic output functions.
use crate::FLOGF;
use crate::color::{Color, Color24};
use crate::common::ToCString;
use crate::common::{self, escape_string, wcs2string, wcs2string_appending, EscapeStringStyle};
use crate::common::{self, EscapeStringStyle, escape_string, wcs2string, wcs2string_appending};
use crate::future_feature_flags::{self, FeatureFlag};
use crate::screen::{is_dumb, only_grayscale};
use crate::text_face::{TextFace, TextStyling, UnderlineStyle};
use crate::threads::MainThread;
use crate::wchar::prelude::*;
use crate::FLOGF;
use bitflags::bitflags;
use std::cell::{RefCell, RefMut};
use std::env;
@@ -16,9 +16,9 @@
use std::os::fd::RawFd;
use std::os::unix::ffi::OsStrExt;
use std::path::PathBuf;
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::{AtomicU8, Ordering};
bitflags! {
#[derive(Copy, Clone, Default)]

View File

@@ -6,8 +6,8 @@
use crate::wchar::prelude::*;
use crate::wutil::fish_wcstoi;
use std::mem::MaybeUninit;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Termsize {

View File

@@ -1,5 +1,5 @@
use crate::abbrs::{self, abbrs_get_set, abbrs_match, Abbreviation};
use crate::editable_line::{apply_edit, Edit};
use crate::abbrs::{self, Abbreviation, abbrs_get_set, abbrs_match};
use crate::editable_line::{Edit, apply_edit};
use crate::highlight::HighlightSpec;
use crate::reader::reader_expand_abbreviation_at_cursor;
use crate::tests::prelude::*;

View File

@@ -1,4 +1,4 @@
use crate::ast::{self, is_same_node, Node};
use crate::ast::{self, Node, is_same_node};
use crate::wchar::prelude::*;
const FISH_FUNC: &str = r#"

View File

@@ -1,4 +1,4 @@
use crate::common::{truncate_at_nul, ScopeGuard, ScopedCell, ScopedRefCell};
use crate::common::{ScopeGuard, ScopedCell, ScopedRefCell, truncate_at_nul};
use crate::wchar::prelude::*;
#[test]

View File

@@ -1,13 +1,13 @@
use crate::abbrs::{self, with_abbrs_mut, Abbreviation};
use crate::abbrs::{self, Abbreviation, with_abbrs_mut};
use crate::complete::{
complete, complete_add, complete_add_wrapper, complete_get_wrap_targets,
complete_remove_wrapper, sort_and_prioritize, CompleteFlags, CompleteOptionType,
CompletionMode, CompletionRequestOptions,
CompleteFlags, CompleteOptionType, CompletionMode, CompletionRequestOptions, complete,
complete_add, complete_add_wrapper, complete_get_wrap_targets, complete_remove_wrapper,
sort_and_prioritize,
};
use crate::env::{EnvMode, Environment};
use crate::io::IoChain;
use crate::operation_context::{
no_cancel, OperationContext, EXPANSION_LIMIT_BACKGROUND, EXPANSION_LIMIT_DEFAULT,
EXPANSION_LIMIT_BACKGROUND, EXPANSION_LIMIT_DEFAULT, OperationContext, no_cancel,
};
use crate::reader::completion_apply_to_command_line;
use crate::tests::prelude::*;
@@ -323,16 +323,20 @@ macro_rules! unique_completion_applies_as {
let completions = do_complete(L!("cat testfile te"), CompletionRequestOptions::default());
assert_eq!(completions.len(), 1);
assert_eq!(completions[0].completion, L!("stfile"));
assert!(completions[0]
.flags
.contains(CompleteFlags::DUPLICATES_ARGUMENT));
assert!(
completions[0]
.flags
.contains(CompleteFlags::DUPLICATES_ARGUMENT)
);
let completions = do_complete(L!("cat testfile TE"), CompletionRequestOptions::default());
assert_eq!(completions.len(), 1);
assert_eq!(completions[0].completion, L!("testfile"));
assert!(completions[0].flags.contains(CompleteFlags::REPLACES_TOKEN));
assert!(completions[0]
.flags
.contains(CompleteFlags::DUPLICATES_ARGUMENT));
assert!(
completions[0]
.flags
.contains(CompleteFlags::DUPLICATES_ARGUMENT)
);
let completions = do_complete(
L!("something --abc=te"),
CompletionRequestOptions::default(),

View File

@@ -1,13 +1,13 @@
use std::sync::{
atomic::{AtomicU32, Ordering},
Arc, Condvar, Mutex,
atomic::{AtomicU32, Ordering},
};
use std::time::Duration;
use crate::global_safety::RelaxedAtomicBool;
use crate::reader::{fake_scoped_reader, Reader};
use crate::reader::{Reader, fake_scoped_reader};
use crate::tests::prelude::*;
use crate::threads::{iothread_drain_all, iothread_service_main, Debounce};
use crate::threads::{Debounce, iothread_drain_all, iothread_service_main};
#[test]
#[serial]

View File

@@ -1,13 +1,13 @@
use crate::common::ENCODE_DIRECT_BASE;
use crate::common::char_offset;
use crate::common::wcs2osstring;
use crate::common::ENCODE_DIRECT_BASE;
use crate::env::{EnvVar, EnvVarFlags, VarTable};
use crate::env_universal_common::{EnvUniversal, UvarFormat};
use crate::reader::fake_scoped_reader;
use crate::tests::prelude::*;
use crate::threads::{iothread_drain_all, iothread_perform};
use crate::wchar::prelude::*;
use crate::wutil::{file_id_for_path, INVALID_FILE_ID};
use crate::wutil::{INVALID_FILE_ID, file_id_for_path};
const UVARS_PER_THREAD: usize = 8;
const UVARS_TEST_PATH: &wstr = L!("test/fish_uvars_test/varsfile.txt");

View File

@@ -3,18 +3,18 @@
use crate::abbrs::{with_abbrs, with_abbrs_mut};
use crate::complete::{CompletionList, CompletionReceiver};
use crate::env::{EnvMode, EnvStackSetResult};
use crate::expand::{expand_to_receiver, ExpandResultCode};
use crate::operation_context::{no_cancel, EXPANSION_LIMIT_DEFAULT};
use crate::expand::{ExpandResultCode, expand_to_receiver};
use crate::operation_context::{EXPANSION_LIMIT_DEFAULT, no_cancel};
use crate::parse_constants::ParseErrorList;
use crate::tests::prelude::*;
use crate::wildcard::ANY_STRING;
use crate::{
expand::{expand_string, ExpandFlags},
expand::{ExpandFlags, expand_string},
operation_context::OperationContext,
wchar::prelude::*,
};
use std::collections::hash_map::RandomState;
use std::collections::HashSet;
use std::collections::hash_map::RandomState;
fn expand_test_impl(
input: &wstr,

View File

@@ -14,7 +14,7 @@
use crate::fd_monitor::{FdEventSignaller, FdMonitor};
use crate::fd_readable_set::{FdReadableSet, Timeout};
use crate::fds::{make_autoclose_pipes, AutoCloseFd, AutoClosePipes};
use crate::fds::{AutoCloseFd, AutoClosePipes, make_autoclose_pipes};
use crate::tests::prelude::*;
/// Helper to make an item which counts how many times its callback was invoked.
@@ -184,11 +184,7 @@ fn do_something_bad_during_select<F>(bad_action: F) -> Result<i32, i32>
// macOS will eagerly return EBADF if the fd is closed; Linux will hit the timeout.
let timeout = Timeout::Duration(Duration::from_millis(500));
let ret = fd_set.check_readable(timeout);
if ret < 0 {
Err(errno().0)
} else {
Ok(ret)
}
if ret < 0 { Err(errno().0) } else { Ok(ret) }
});
barrier.wait();
@@ -204,7 +200,7 @@ fn do_something_bad_during_select<F>(bad_action: F) -> Result<i32, i32>
#[test]
fn test_close_during_select_ebadf() {
use crate::common::{is_windows_subsystem_for_linux as is_wsl, WSL};
use crate::common::{WSL, is_windows_subsystem_for_linux as is_wsl};
let close_it = |read_fd: OwnedFd| {
drop(read_fd);
None

View File

@@ -1,4 +1,4 @@
use crate::common::{is_windows_subsystem_for_linux, str2wcstring, wcs2osstring, wcs2string, WSL};
use crate::common::{WSL, is_windows_subsystem_for_linux, str2wcstring, wcs2osstring, wcs2string};
use crate::env::{EnvMode, EnvStack};
use crate::history::{
self, History, HistoryItem, HistorySearch, PathList, SearchDirection, VACUUM_FREQUENCY,
@@ -10,8 +10,8 @@
use crate::wchar::prelude::*;
use crate::wcstringutil::{string_prefixes_string, string_prefixes_string_case_insensitive};
use fish_build_helper::workspace_root;
use rand::rngs::SmallRng;
use rand::Rng;
use rand::rngs::SmallRng;
use std::collections::VecDeque;
use std::ffi::CString;
use std::io::BufReader;

View File

@@ -1,5 +1,5 @@
use crate::env::EnvStack;
use crate::input::{EventQueuePeeker, InputMappingSet, KeyNameStyle, DEFAULT_BIND_MODE};
use crate::input::{DEFAULT_BIND_MODE, EventQueuePeeker, InputMappingSet, KeyNameStyle};
use crate::input_common::{CharEvent, InputData, InputEventQueuer, KeyEvent};
use crate::key::Key;
use crate::wchar::prelude::*;

View File

@@ -1,4 +1,4 @@
use crate::key::{self, ctrl, function_key, parse_keys, Key};
use crate::key::{self, Key, ctrl, function_key, parse_keys};
use crate::wchar::prelude::*;
#[test]

View File

@@ -29,7 +29,7 @@
mod wgetopt;
pub mod prelude {
use crate::common::{ScopeGuard, ScopeGuarding, BUILD_DIR};
use crate::common::{BUILD_DIR, ScopeGuard, ScopeGuarding};
use crate::env::{env_init, misc_init};
use crate::parser::{CancelBehavior, Parser};
use crate::reader::{reader_deinit, reader_init};

View File

@@ -2,14 +2,14 @@
use crate::common::EscapeFlags;
use crate::parse_constants::{
ERROR_BAD_VAR_CHAR1, ERROR_BRACKETED_VARIABLE1, ERROR_BRACKETED_VARIABLE_QUOTED1,
ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR, ERROR_NOT_PID, ERROR_NOT_STATUS,
ERROR_NO_VAR_NAME,
ERROR_BAD_VAR_CHAR1, ERROR_BRACKETED_VARIABLE_QUOTED1, ERROR_BRACKETED_VARIABLE1,
ERROR_NO_VAR_NAME, ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR, ERROR_NOT_PID,
ERROR_NOT_STATUS,
};
use crate::parse_util::{
parse_util_cmdsubst_extent, parse_util_compute_indents, parse_util_detect_errors,
parse_util_escape_string_with_quote, parse_util_process_extent, parse_util_slice_length,
BOOL_AFTER_BACKGROUND_ERROR_MSG,
BOOL_AFTER_BACKGROUND_ERROR_MSG, parse_util_cmdsubst_extent, parse_util_compute_indents,
parse_util_detect_errors, parse_util_escape_string_with_quote, parse_util_process_extent,
parse_util_slice_length,
};
use crate::tests::prelude::*;
use crate::wchar::prelude::*;

View File

@@ -1,11 +1,11 @@
use crate::ast::{self, is_same_node, Ast, Castable, JobList, JobPipeline, Kind, Node, Traversal};
use crate::ast::{self, Ast, Castable, JobList, JobPipeline, Kind, Node, Traversal, is_same_node};
use crate::env::EnvStack;
use crate::expand::ExpandFlags;
use crate::io::{IoBufferfill, IoChain};
use crate::parse_constants::{
ParseErrorCode, ParseTokenType, ParseTreeFlags, ParserTestErrorBits, StatementDecoration,
};
use crate::parse_tree::{parse_source, LineCounter};
use crate::parse_tree::{LineCounter, parse_source};
use crate::parse_util::{parse_util_detect_errors, parse_util_detect_errors_in_argument};
use crate::parser::{CancelBehavior, Parser};
use crate::reader::{fake_scoped_reader, reader_reset_interrupted};

View File

@@ -1,5 +1,5 @@
use crate::complete::CompleteFlags;
use crate::operation_context::{no_cancel, OperationContext};
use crate::operation_context::{OperationContext, no_cancel};
use crate::reader::{combine_command_and_autosuggestion, completion_apply_to_command_line};
use crate::tests::prelude::*;
use crate::wchar::prelude::*;

Some files were not shown because too many files have changed in this diff Show More