From 894d4ecc538279ab7014aaa059f3405199bc35a7 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Thu, 7 Aug 2025 21:25:42 +0000 Subject: [PATCH] Update to Rust 1.89, address newly added lints --- .github/actions/rust-toolchain@stable/action.yml | 2 +- rust-toolchain.toml | 2 +- src/ast.rs | 16 ++++++++-------- src/env/environment.rs | 4 ++-- src/env/environment_impl.rs | 2 +- src/history.rs | 4 ++-- src/history/file.rs | 4 ++-- src/operation_context.rs | 4 ++-- src/proc.rs | 4 ++-- src/wchar_ext.rs | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/actions/rust-toolchain@stable/action.yml b/.github/actions/rust-toolchain@stable/action.yml index ea3c484bd..46f74ed26 100644 --- a/.github/actions/rust-toolchain@stable/action.yml +++ b/.github/actions/rust-toolchain@stable/action.yml @@ -17,7 +17,7 @@ runs: using: "composite" steps: # also update in rust-toolchain.toml - - uses: dtolnay/rust-toolchain@1.88.0 + - uses: dtolnay/rust-toolchain@1.89.0 with: targets: ${{ inputs.targets }} components: ${{ inputs.components }} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e989b7bee..bd30ff00d 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] # also update in .github/actions/rust-toolchain@stable/action.yml -channel = "1.88.0" +channel = "1.89.0" diff --git a/src/ast.rs b/src/ast.rs index d1ab7b2d8..aff099d13 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -123,10 +123,10 @@ fn accept_mut(&mut self, visitor: &mut V) { /// Node is the base trait of all AST nodes. pub trait Node: Acceptor + AsNode + std::fmt::Debug { /// Return the kind of this node. - fn kind(&self) -> Kind; + fn kind(&self) -> Kind<'_>; /// Return the kind of this node, as a mutable reference. - fn kind_mut(&mut self) -> KindMut; + fn kind_mut(&mut self) -> KindMut<'_>; /// Helper to try to cast to a keyword. fn as_keyword(&self) -> Option<&dyn Keyword> { @@ -407,10 +407,10 @@ trait CheckParse: Default { macro_rules! implement_node { ( $name:ident ) => { impl Node for $name { - fn kind(&self) -> Kind { + fn kind(&self) -> Kind<'_> { Kind::$name(self) } - fn kind_mut(&mut self) -> KindMut { + fn kind_mut(&mut self) -> KindMut<'_> { KindMut::$name(self) } } @@ -462,10 +462,10 @@ pub struct $name { } implement_leaf!($name); impl Node for $name { - fn kind(&self) -> Kind { + fn kind(&self) -> Kind<'_> { Kind::Keyword(self) } - fn kind_mut(&mut self) -> KindMut { + fn kind_mut(&mut self) -> KindMut<'_> { KindMut::Keyword(self) } } @@ -495,10 +495,10 @@ pub struct $name { parse_token_type: ParseTokenType, } impl Node for $name { - fn kind(&self) -> Kind { + fn kind(&self) -> Kind<'_> { Kind::Token(self) } - fn kind_mut(&mut self) -> KindMut { + fn kind_mut(&mut self) -> KindMut<'_> { KindMut::Token(self) } } diff --git a/src/env/environment.rs b/src/env/environment.rs index dcfd11261..2e7c05f3f 100644 --- a/src/env/environment.rs +++ b/src/env/environment.rs @@ -164,7 +164,7 @@ fn from_impl(inner: EnvMutex) -> EnvScoped { EnvScoped { inner } } - fn lock(&self) -> EnvMutexGuard { + fn lock(&self) -> EnvMutexGuard<'_, EnvScopedImpl> { self.inner.lock() } } @@ -199,7 +199,7 @@ pub fn create_child(&self, dispatches_var_changes: bool) -> EnvStack { } } - fn lock(&self) -> EnvMutexGuard { + fn lock(&self) -> EnvMutexGuard<'_, EnvStackImpl> { self.inner.lock() } diff --git a/src/env/environment_impl.rs b/src/env/environment_impl.rs index 96b03e2af..747ba718f 100644 --- a/src/env/environment_impl.rs +++ b/src/env/environment_impl.rs @@ -1139,7 +1139,7 @@ pub fn new(inner: T) -> Self { } } - pub fn lock(&self) -> EnvMutexGuard { + pub fn lock(&self) -> EnvMutexGuard<'_, T> { let guard = ENV_LOCK.lock().unwrap(); // Safety: we have the global lock. let value = unsafe { &mut *self.inner.get() }; diff --git a/src/history.rs b/src/history.rs index 48a0cbbb1..4f66d2957 100644 --- a/src/history.rs +++ b/src/history.rs @@ -1093,7 +1093,7 @@ fn set_valid_file_paths(&mut self, valid_file_paths: Vec, ident: Histor /// Return the specified history at the specified index. 0 is the index of the current /// commandline. (So the most recent item is at index 1.) - fn item_at_index(&mut self, mut idx: usize) -> Option> { + fn item_at_index(&mut self, mut idx: usize) -> Option> { // 0 is considered an invalid index. if idx == 0 { return None; @@ -1255,7 +1255,7 @@ fn should_import_bash_history_line(line: &wstr) -> bool { pub struct History(Mutex); impl History { - fn imp(&self) -> MutexGuard { + fn imp(&self) -> MutexGuard<'_, HistoryImpl> { self.0.lock().unwrap() } diff --git a/src/history/file.rs b/src/history/file.rs index 0dfb63ae3..57ed1c86f 100644 --- a/src/history/file.rs +++ b/src/history/file.rs @@ -262,7 +262,7 @@ fn escape_yaml_fish_2_0(s: &mut Vec) { #[inline(always)] /// Unescapes the fish-specific yaml variant, if it requires it. -fn maybe_unescape_yaml_fish_2_0(s: &[u8]) -> Cow<[u8]> { +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.iter().copied().fold(false, |acc, b| acc | (b == b'\\')) { @@ -348,7 +348,7 @@ fn trim_leading_spaces(s: &[u8]) -> (usize, &[u8]) { // unescape_yaml_fish_2_0() for the discarded key. #[inline(always)] #[allow(clippy::type_complexity)] -fn extract_prefix_and_unescape_yaml(line: &[u8]) -> Option<(Cow<[u8]>, Cow<[u8]>)> { +fn extract_prefix_and_unescape_yaml(line: &[u8]) -> Option<(Cow<'_, [u8]>, Cow<'_, [u8]>)> { let mut split = line.splitn(2, |c| *c == b':'); let key = split.next().unwrap(); let value = split.next()?; diff --git a/src/operation_context.rs b/src/operation_context.rs index e7b3bf0e1..34995f9b4 100644 --- a/src/operation_context.rs +++ b/src/operation_context.rs @@ -119,7 +119,7 @@ pub fn background_with_cancel_checker( } } - pub fn background_interruptible(env: &dyn Environment) -> OperationContext { + pub fn background_interruptible(env: &dyn Environment) -> OperationContext<'_> { OperationContext::background_with_cancel_checker( env, Box::new(|| signal_check_cancel() != 0), @@ -153,7 +153,7 @@ pub fn check_cancel(&self) -> bool { /// Return an operation context for a background operation.. /// Crucially the operation context itself does not contain a parser. /// It is the caller's responsibility to ensure the environment lives as long as the result. -pub fn get_bg_context(env: &EnvDyn, generation_count: u32) -> OperationContext { +pub fn get_bg_context(env: &EnvDyn, generation_count: u32) -> OperationContext<'_> { let cancel_checker = move || { // Cancel if the generation count changed. generation_count != read_generation_count() diff --git a/src/proc.rs b/src/proc.rs index 06ece37e2..dc7c5dc0e 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -680,12 +680,12 @@ pub fn job_id(&self) -> MaybeJobId { } /// Access the job flags. - pub fn flags(&self) -> Ref { + pub fn flags(&self) -> Ref<'_, JobFlags> { self.job_flags.borrow() } /// Access mutable job flags. - pub fn mut_flags(&self) -> RefMut { + pub fn mut_flags(&self) -> RefMut<'_, JobFlags> { self.job_flags.borrow_mut() } diff --git a/src/wchar_ext.rs b/src/wchar_ext.rs index 375b9aef5..89c96254d 100644 --- a/src/wchar_ext.rs +++ b/src/wchar_ext.rs @@ -237,7 +237,7 @@ fn try_char_at(&self, index: usize) -> Option { /// Return an iterator over substrings, split by a given char. /// The split char is not included in the substrings. - fn split(&self, c: char) -> WStrCharSplitIter { + fn split(&self, c: char) -> WStrCharSplitIter<'_> { WStrCharSplitIter { split: c, chars: Some(self.as_char_slice()),