Skip to content

Commit

Permalink
fix: assorted non-fatal clippy warnings (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
reubeno authored Nov 28, 2024
1 parent 7ca1f25 commit e4135f1
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions brush-core/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,7 @@ impl Config {
simple_tokenize_by_delimiters(input, &default_delimiters)
}

async fn get_completions_for_token<'a>(
&self,
shell: &mut Shell,
context: Context<'a>,
) -> Answer {
async fn get_completions_for_token(&self, shell: &mut Shell, context: Context<'_>) -> Answer {
// See if we can find a completion spec matching the current command.
let mut found_spec: Option<&Spec> = None;

Expand Down
5 changes: 5 additions & 0 deletions brush-core/src/expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ impl<'a> WordExpander<'a> {
Ok(expanded)
}

#[allow(clippy::ref_option)]
async fn basic_expand_opt_pattern(
&mut self,
word: &Option<String>,
Expand Down Expand Up @@ -1337,6 +1338,7 @@ impl<'a> WordExpander<'a> {
}

#[allow(clippy::unwrap_in_result)]
#[allow(clippy::ref_option)]
fn uppercase_first_char(
s: String,
pattern: &Option<patterns::Pattern>,
Expand All @@ -1362,6 +1364,7 @@ impl<'a> WordExpander<'a> {
}

#[allow(clippy::unwrap_in_result)]
#[allow(clippy::ref_option)]
fn lowercase_first_char(
s: String,
pattern: &Option<patterns::Pattern>,
Expand All @@ -1386,6 +1389,7 @@ impl<'a> WordExpander<'a> {
}
}

#[allow(clippy::ref_option)]
fn uppercase_pattern(
s: &str,
pattern: &Option<patterns::Pattern>,
Expand All @@ -1405,6 +1409,7 @@ impl<'a> WordExpander<'a> {
}
}

#[allow(clippy::ref_option)]
fn lowercase_pattern(
s: &str,
pattern: &Option<patterns::Pattern>,
Expand Down
4 changes: 2 additions & 2 deletions brush-core/src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ fn setup_pipeline_redirection(
}

#[allow(clippy::too_many_lines)]
pub(crate) async fn setup_redirect<'a>(
open_files: &'a mut OpenFiles,
pub(crate) async fn setup_redirect(
open_files: &'_ mut OpenFiles,
shell: &mut Shell,
redirect: &ast::IoRedirect,
) -> Result<Option<u32>, error::Error> {
Expand Down
4 changes: 4 additions & 0 deletions brush-core/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ fn pattern_to_regex_str(
/// * `s` - The string to remove the prefix from.
/// * `pattern` - The pattern to match.
/// * `enable_extended_globbing` - Whether or not to enable extended globbing (extglob).
#[allow(clippy::ref_option)]
pub(crate) fn remove_largest_matching_prefix<'a>(
s: &'a str,
pattern: &Option<Pattern>,
Expand All @@ -416,6 +417,7 @@ pub(crate) fn remove_largest_matching_prefix<'a>(
/// * `s` - The string to remove the prefix from.
/// * `pattern` - The pattern to match.
/// * `enable_extended_globbing` - Whether or not to enable extended globbing (extglob).
#[allow(clippy::ref_option)]
pub(crate) fn remove_smallest_matching_prefix<'a>(
s: &'a str,
pattern: &Option<Pattern>,
Expand All @@ -438,6 +440,7 @@ pub(crate) fn remove_smallest_matching_prefix<'a>(
/// * `s` - The string to remove the suffix from.
/// * `pattern` - The pattern to match.
/// * `enable_extended_globbing` - Whether or not to enable extended globbing (extglob).
#[allow(clippy::ref_option)]
pub(crate) fn remove_largest_matching_suffix<'a>(
s: &'a str,
pattern: &Option<Pattern>,
Expand All @@ -460,6 +463,7 @@ pub(crate) fn remove_largest_matching_suffix<'a>(
/// * `s` - The string to remove the suffix from.
/// * `pattern` - The pattern to match.
/// * `enable_extended_globbing` - Whether or not to enable extended globbing (extglob).
#[allow(clippy::ref_option)]
pub(crate) fn remove_smallest_matching_suffix<'a>(
s: &'a str,
pattern: &Option<Pattern>,
Expand Down
4 changes: 2 additions & 2 deletions brush-interactive/src/reedline/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) struct ReedlineShellReader<'a> {
pub shell: MutexGuard<'a, brush_core::Shell>,
}

impl<'a> AsRef<brush_core::Shell> for ReedlineShellReader<'a> {
impl AsRef<brush_core::Shell> for ReedlineShellReader<'_> {
fn as_ref(&self) -> &brush_core::Shell {
self.shell.borrow()
}
Expand All @@ -21,7 +21,7 @@ pub(crate) struct ReedlineShellWriter<'a> {
pub shell: MutexGuard<'a, brush_core::Shell>,
}

impl<'a> AsMut<brush_core::Shell> for ReedlineShellWriter<'a> {
impl AsMut<brush_core::Shell> for ReedlineShellWriter<'_> {
fn as_mut(&mut self) -> &mut brush_core::Shell {
self.shell.borrow_mut()
}
Expand Down
2 changes: 1 addition & 1 deletion brush-parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn parse_tokens(
result
}

impl<'a> peg::Parse for Tokens<'a> {
impl peg::Parse for Tokens<'_> {
type PositionRepr = usize;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion brush-parser/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ impl<'a, R: ?Sized + std::io::BufRead> Tokenizer<'a, R> {
}
}

impl<'a, R: ?Sized + std::io::BufRead> Iterator for Tokenizer<'a, R> {
impl<R: ?Sized + std::io::BufRead> Iterator for Tokenizer<'_, R> {
type Item = Result<TokenizeResult, TokenizerError>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down

0 comments on commit e4135f1

Please sign in to comment.