mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
Update to Rust 1.89, address newly added lints
This commit is contained in:
@@ -17,7 +17,7 @@ runs:
|
|||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
# also update in rust-toolchain.toml
|
# also update in rust-toolchain.toml
|
||||||
- uses: dtolnay/rust-toolchain@1.88.0
|
- uses: dtolnay/rust-toolchain@1.89.0
|
||||||
with:
|
with:
|
||||||
targets: ${{ inputs.targets }}
|
targets: ${{ inputs.targets }}
|
||||||
components: ${{ inputs.components }}
|
components: ${{ inputs.components }}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
# also update in .github/actions/rust-toolchain@stable/action.yml
|
# also update in .github/actions/rust-toolchain@stable/action.yml
|
||||||
channel = "1.88.0"
|
channel = "1.89.0"
|
||||||
|
|||||||
16
src/ast.rs
16
src/ast.rs
@@ -123,10 +123,10 @@ fn accept_mut<V: NodeVisitorMut>(&mut self, visitor: &mut V) {
|
|||||||
/// Node is the base trait of all AST nodes.
|
/// Node is the base trait of all AST nodes.
|
||||||
pub trait Node: Acceptor + AsNode + std::fmt::Debug {
|
pub trait Node: Acceptor + AsNode + std::fmt::Debug {
|
||||||
/// Return the kind of this node.
|
/// Return the kind of this node.
|
||||||
fn kind(&self) -> Kind;
|
fn kind(&self) -> Kind<'_>;
|
||||||
|
|
||||||
/// Return the kind of this node, as a mutable reference.
|
/// 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.
|
/// Helper to try to cast to a keyword.
|
||||||
fn as_keyword(&self) -> Option<&dyn Keyword> {
|
fn as_keyword(&self) -> Option<&dyn Keyword> {
|
||||||
@@ -407,10 +407,10 @@ trait CheckParse: Default {
|
|||||||
macro_rules! implement_node {
|
macro_rules! implement_node {
|
||||||
( $name:ident ) => {
|
( $name:ident ) => {
|
||||||
impl Node for $name {
|
impl Node for $name {
|
||||||
fn kind(&self) -> Kind {
|
fn kind(&self) -> Kind<'_> {
|
||||||
Kind::$name(self)
|
Kind::$name(self)
|
||||||
}
|
}
|
||||||
fn kind_mut(&mut self) -> KindMut {
|
fn kind_mut(&mut self) -> KindMut<'_> {
|
||||||
KindMut::$name(self)
|
KindMut::$name(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,10 +462,10 @@ pub struct $name {
|
|||||||
}
|
}
|
||||||
implement_leaf!($name);
|
implement_leaf!($name);
|
||||||
impl Node for $name {
|
impl Node for $name {
|
||||||
fn kind(&self) -> Kind {
|
fn kind(&self) -> Kind<'_> {
|
||||||
Kind::Keyword(self)
|
Kind::Keyword(self)
|
||||||
}
|
}
|
||||||
fn kind_mut(&mut self) -> KindMut {
|
fn kind_mut(&mut self) -> KindMut<'_> {
|
||||||
KindMut::Keyword(self)
|
KindMut::Keyword(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,10 +495,10 @@ pub struct $name {
|
|||||||
parse_token_type: ParseTokenType,
|
parse_token_type: ParseTokenType,
|
||||||
}
|
}
|
||||||
impl Node for $name {
|
impl Node for $name {
|
||||||
fn kind(&self) -> Kind {
|
fn kind(&self) -> Kind<'_> {
|
||||||
Kind::Token(self)
|
Kind::Token(self)
|
||||||
}
|
}
|
||||||
fn kind_mut(&mut self) -> KindMut {
|
fn kind_mut(&mut self) -> KindMut<'_> {
|
||||||
KindMut::Token(self)
|
KindMut::Token(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/env/environment.rs
vendored
4
src/env/environment.rs
vendored
@@ -164,7 +164,7 @@ fn from_impl(inner: EnvMutex<EnvScopedImpl>) -> EnvScoped {
|
|||||||
EnvScoped { inner }
|
EnvScoped { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lock(&self) -> EnvMutexGuard<EnvScopedImpl> {
|
fn lock(&self) -> EnvMutexGuard<'_, EnvScopedImpl> {
|
||||||
self.inner.lock()
|
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()
|
self.inner.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
src/env/environment_impl.rs
vendored
2
src/env/environment_impl.rs
vendored
@@ -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();
|
let guard = ENV_LOCK.lock().unwrap();
|
||||||
// Safety: we have the global lock.
|
// Safety: we have the global lock.
|
||||||
let value = unsafe { &mut *self.inner.get() };
|
let value = unsafe { &mut *self.inner.get() };
|
||||||
|
|||||||
@@ -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
|
/// 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.)
|
/// 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.
|
// 0 is considered an invalid index.
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
return None;
|
return None;
|
||||||
@@ -1255,7 +1255,7 @@ fn should_import_bash_history_line(line: &wstr) -> bool {
|
|||||||
pub struct History(Mutex<HistoryImpl>);
|
pub struct History(Mutex<HistoryImpl>);
|
||||||
|
|
||||||
impl History {
|
impl History {
|
||||||
fn imp(&self) -> MutexGuard<HistoryImpl> {
|
fn imp(&self) -> MutexGuard<'_, HistoryImpl> {
|
||||||
self.0.lock().unwrap()
|
self.0.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ fn escape_yaml_fish_2_0(s: &mut Vec<u8>) {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
/// Unescapes the fish-specific yaml variant, if it requires it.
|
/// 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
|
// This is faster than s.contains(b'\\') and can be auto-vectorized to SIMD. See benchmark note
|
||||||
// on unescape_yaml_fish_2_0().
|
// on unescape_yaml_fish_2_0().
|
||||||
if !s.iter().copied().fold(false, |acc, b| acc | (b == b'\\')) {
|
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.
|
// unescape_yaml_fish_2_0() for the discarded key.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(clippy::type_complexity)]
|
#[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 mut split = line.splitn(2, |c| *c == b':');
|
||||||
let key = split.next().unwrap();
|
let key = split.next().unwrap();
|
||||||
let value = split.next()?;
|
let value = split.next()?;
|
||||||
|
|||||||
@@ -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(
|
OperationContext::background_with_cancel_checker(
|
||||||
env,
|
env,
|
||||||
Box::new(|| signal_check_cancel() != 0),
|
Box::new(|| signal_check_cancel() != 0),
|
||||||
@@ -153,7 +153,7 @@ pub fn check_cancel(&self) -> bool {
|
|||||||
/// Return an operation context for a background operation..
|
/// Return an operation context for a background operation..
|
||||||
/// Crucially the operation context itself does not contain a parser.
|
/// 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.
|
/// 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 || {
|
let cancel_checker = move || {
|
||||||
// Cancel if the generation count changed.
|
// Cancel if the generation count changed.
|
||||||
generation_count != read_generation_count()
|
generation_count != read_generation_count()
|
||||||
|
|||||||
@@ -680,12 +680,12 @@ pub fn job_id(&self) -> MaybeJobId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Access the job flags.
|
/// Access the job flags.
|
||||||
pub fn flags(&self) -> Ref<JobFlags> {
|
pub fn flags(&self) -> Ref<'_, JobFlags> {
|
||||||
self.job_flags.borrow()
|
self.job_flags.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access mutable job flags.
|
/// Access mutable job flags.
|
||||||
pub fn mut_flags(&self) -> RefMut<JobFlags> {
|
pub fn mut_flags(&self) -> RefMut<'_, JobFlags> {
|
||||||
self.job_flags.borrow_mut()
|
self.job_flags.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ fn try_char_at(&self, index: usize) -> Option<char> {
|
|||||||
|
|
||||||
/// Return an iterator over substrings, split by a given char.
|
/// Return an iterator over substrings, split by a given char.
|
||||||
/// The split char is not included in the substrings.
|
/// The split char is not included in the substrings.
|
||||||
fn split(&self, c: char) -> WStrCharSplitIter {
|
fn split(&self, c: char) -> WStrCharSplitIter<'_> {
|
||||||
WStrCharSplitIter {
|
WStrCharSplitIter {
|
||||||
split: c,
|
split: c,
|
||||||
chars: Some(self.as_char_slice()),
|
chars: Some(self.as_char_slice()),
|
||||||
|
|||||||
Reference in New Issue
Block a user