diff --git a/src/builtins/string/length.rs b/src/builtins/string/length.rs index 14da55951..8c4ede64a 100644 --- a/src/builtins/string/length.rs +++ b/src/builtins/string/length.rs @@ -45,7 +45,7 @@ impl StringSubCommand<'_> for Length { let val = &line; val.split('\r') } { - let n = width_without_escapes(&reset, 0); + let n = width_without_escapes(reset, 0); max = usize::max(max, n); } if max > 0 { diff --git a/src/builtins/string/shorten.rs b/src/builtins/string/shorten.rs index 48c7b7d77..ce84e8afe 100644 --- a/src/builtins/string/shorten.rs +++ b/src/builtins/string/shorten.rs @@ -108,7 +108,7 @@ impl<'args> StringSubCommand<'args> for Shorten<'args> { inputs.push(s); } else { for s in splits { - let width = width_without_escapes(&s, 0); + let width = width_without_escapes(s, 0); if width > 0 && width < min_width { min_width = width; } diff --git a/src/env/environment.rs b/src/env/environment.rs index 3fcdaf6d8..008b547a3 100644 --- a/src/env/environment.rs +++ b/src/env/environment.rs @@ -363,14 +363,14 @@ impl EnvStack { pub fn globals() -> &'static EnvStack { use std::sync::OnceLock; static GLOBALS: OnceLock = OnceLock::new(); - GLOBALS.get_or_init(|| EnvStack::new()) + GLOBALS.get_or_init(EnvStack::new) } /// Access the principal variable stack, associated with the principal parser. pub fn principal() -> &'static Arc { use std::sync::OnceLock; static PRINCIPAL_STACK: OnceLock> = OnceLock::new(); - &PRINCIPAL_STACK.get_or_init(|| Arc::new(EnvStack::new())) + PRINCIPAL_STACK.get_or_init(|| Arc::new(EnvStack::new())) } pub fn set_argv(&self, argv: Vec) { diff --git a/src/history/file.rs b/src/history/file.rs index a8c7a7cbd..50ad3c4d3 100644 --- a/src/history/file.rs +++ b/src/history/file.rs @@ -255,11 +255,7 @@ fn escape_yaml_fish_2_0(s: &mut Vec) { fn maybe_unescape_yaml_fish_2_0(s: &[u8]) -> Cow<[u8]> { // This is faster than s.contains(b'\\') and can be auto-vectorized to SIMD. See benchmark note // on unescape_yaml_fish_2_0(). - if !s - .into_iter() - .copied() - .fold(false, |acc, b| acc | (b == b'\\')) - { + if !s.iter().copied().fold(false, |acc, b| acc | (b == b'\\')) { return s.into(); } unescape_yaml_fish_2_0(s).into() @@ -412,7 +408,7 @@ fn decode_item_fish_2_0(mut data: &[u8]) -> Option { // We're going to consume this line. data = &data[advance..]; - let line = maybe_unescape_yaml_fish_2_0(&line); + let line = maybe_unescape_yaml_fish_2_0(line); paths.push(str2wcstring(&line)); } } diff --git a/src/operation_context.rs b/src/operation_context.rs index d2a443df3..1f4b859c9 100644 --- a/src/operation_context.rs +++ b/src/operation_context.rs @@ -58,7 +58,7 @@ impl<'a> OperationContext<'a> { pub fn empty() -> OperationContext<'static> { use std::sync::OnceLock; static NULL_ENV: OnceLock = OnceLock::new(); - let null_env = NULL_ENV.get_or_init(|| EnvStack::new()); + let null_env = NULL_ENV.get_or_init(EnvStack::new); OperationContext::background(null_env, EXPANSION_LIMIT_DEFAULT) } diff --git a/src/parser.rs b/src/parser.rs index 4c343e85d..585d7b782 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -402,7 +402,7 @@ impl Parser { pub fn principal_parser() -> &'static Parser { use std::cell::OnceCell; static PRINCIPAL: MainThread> = MainThread::new(OnceCell::new()); - &PRINCIPAL + PRINCIPAL .get() // The parser is !Send/!Sync and strictly single-threaded, but we can have // multi-threaded access to its variables stack (why, though?) so EnvStack::principal() diff --git a/src/path.rs b/src/path.rs index 7b6771d41..ad86bc915 100644 --- a/src/path.rs +++ b/src/path.rs @@ -321,15 +321,14 @@ fn path_get_path_core>(cmd: &wstr, pathsv: &[S]) -> GetPathResult let p = p.as_ref(); p.starts_with("/mnt/") && p.chars() - .skip("/mnt/x".len()) - .next() + .nth("/mnt/x".len()) .map(|c| c == '/') .unwrap_or(false) }) .count(); &pathsv[..pathsv.len() - win_path_count] } else { - &pathsv + pathsv }; let mut best = noent_res; diff --git a/src/threads.rs b/src/threads.rs index a25cad09d..d75b8934e 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -102,7 +102,7 @@ fn thread_id() -> usize { fn test_thread_ids() { let start_thread_id = thread_id(); assert_eq!(start_thread_id, thread_id()); - let spawned_thread_id = std::thread::spawn(|| thread_id()).join(); + let spawned_thread_id = std::thread::spawn(thread_id).join(); assert_ne!(start_thread_id, spawned_thread_id.unwrap()); }