Update to Rust 1.89, address newly added lints

This commit is contained in:
Xiretza
2025-08-07 21:25:42 +00:00
parent f806d35af8
commit 894d4ecc53
10 changed files with 22 additions and 22 deletions

View File

@@ -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 }}

View File

@@ -1,3 +1,3 @@
[toolchain]
# also update in .github/actions/rust-toolchain@stable/action.yml
channel = "1.88.0"
channel = "1.89.0"

View File

@@ -123,10 +123,10 @@ fn accept_mut<V: NodeVisitorMut>(&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)
}
}

View File

@@ -164,7 +164,7 @@ fn from_impl(inner: EnvMutex<EnvScopedImpl>) -> EnvScoped {
EnvScoped { inner }
}
fn lock(&self) -> EnvMutexGuard<EnvScopedImpl> {
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<EnvStackImpl> {
fn lock(&self) -> EnvMutexGuard<'_, EnvStackImpl> {
self.inner.lock()
}

View File

@@ -1139,7 +1139,7 @@ pub fn new(inner: T) -> Self {
}
}
pub fn lock(&self) -> EnvMutexGuard<T> {
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() };

View File

@@ -1093,7 +1093,7 @@ fn set_valid_file_paths(&mut self, valid_file_paths: Vec<WString>, 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<Cow<HistoryItem>> {
fn item_at_index(&mut self, mut idx: usize) -> Option<Cow<'_, HistoryItem>> {
// 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<HistoryImpl>);
impl History {
fn imp(&self) -> MutexGuard<HistoryImpl> {
fn imp(&self) -> MutexGuard<'_, HistoryImpl> {
self.0.lock().unwrap()
}

View File

@@ -262,7 +262,7 @@ fn escape_yaml_fish_2_0(s: &mut Vec<u8>) {
#[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()?;

View File

@@ -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()

View File

@@ -680,12 +680,12 @@ pub fn job_id(&self) -> MaybeJobId {
}
/// Access the job flags.
pub fn flags(&self) -> Ref<JobFlags> {
pub fn flags(&self) -> Ref<'_, JobFlags> {
self.job_flags.borrow()
}
/// Access mutable job flags.
pub fn mut_flags(&self) -> RefMut<JobFlags> {
pub fn mut_flags(&self) -> RefMut<'_, JobFlags> {
self.job_flags.borrow_mut()
}

View File

@@ -237,7 +237,7 @@ fn try_char_at(&self, index: usize) -> Option<char> {
/// 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()),