From 2fb352a9e4d46131f8a593a54893b61e222680e2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 3 Oct 2023 06:34:55 -0500 Subject: [PATCH] Address some clippy lints from nightly clippy Note that in general we should not respect nightly clippy because it might contradict stable clippy which is run in CI. --- fish-rust/src/builtins/random.rs | 2 +- fish-rust/src/io.rs | 6 +++--- fish-rust/src/tokenizer.rs | 6 +++--- fish-rust/src/wildcard.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fish-rust/src/builtins/random.rs b/fish-rust/src/builtins/random.rs index 0b47ae6ba..76b33d9c8 100644 --- a/fish-rust/src/builtins/random.rs +++ b/fish-rust/src/builtins/random.rs @@ -21,7 +21,7 @@ pub fn random( const longopts: &[woption] = &[wopt(L!("help"), woption_argument_t::no_argument, 'h')]; let mut w = wgetopter_t::new(shortopts, longopts, argv); - while let Some(c) = w.wgetopt_long() { + if let Some(c) = w.wgetopt_long() { match c { 'h' => { builtin_print_help(parser, streams, cmd); diff --git a/fish-rust/src/io.rs b/fish-rust/src/io.rs index 86838d29b..6c37cba16 100644 --- a/fish-rust/src/io.rs +++ b/fish-rust/src/io.rs @@ -352,8 +352,8 @@ pub fn create(buffer_limit: usize, target: RawFd) -> Option> { } } // Our fillthread gets the read end of the pipe; out_pipe gets the write end. - let mut buffer = Arc::new(RwLock::new(IoBuffer::new(buffer_limit))); - begin_filling(&mut buffer, pipes.read); + let buffer = Arc::new(RwLock::new(IoBuffer::new(buffer_limit))); + begin_filling(&buffer, pipes.read); assert!(pipes.write.is_valid(), "fd is not valid"); Some(Rc::new(IoBufferfill { target, @@ -511,7 +511,7 @@ pub fn fillthread_running(&self) -> bool { } /// Begin the fill operation, reading from the given fd in the background. -fn begin_filling(iobuffer: &mut Arc>, fd: AutoCloseFd) { +fn begin_filling(iobuffer: &Arc>, fd: AutoCloseFd) { assert!( !iobuffer.read().unwrap().fillthread_running(), "Already have a fillthread" diff --git a/fish-rust/src/tokenizer.rs b/fish-rust/src/tokenizer.rs index 23ce55217..8c1d3b9f5 100644 --- a/fish-rust/src/tokenizer.rs +++ b/fish-rust/src/tokenizer.rs @@ -634,7 +634,7 @@ fn read_string(&mut self) -> Tok { fn process_opening_quote( this: &mut Tokenizer, quoted_cmdsubs: &mut Vec, - paran_offsets: &mut Vec, + paran_offsets: &Vec, quote: char, ) -> Result<(), usize> { if let Some(end) = quote_end(&this.start, this.token_cursor, quote) { @@ -705,7 +705,7 @@ fn process_opening_quote( // The "$(" part of a quoted command substitution closes double quotes. To keep // quotes balanced, act as if there was an invisible double quote after the ")". if let Err(error_loc) = - process_opening_quote(self, &mut quoted_cmdsubs, &mut paran_offsets, '"') + process_opening_quote(self, &mut quoted_cmdsubs, ¶n_offsets, '"') { if !self.accept_unfinished { return self.call_error( @@ -759,7 +759,7 @@ fn process_opening_quote( mode &= !TOK_MODE_ARRAY_BRACKETS; } else if c == '\'' || c == '"' { if let Err(error_loc) = - process_opening_quote(self, &mut quoted_cmdsubs, &mut paran_offsets, c) + process_opening_quote(self, &mut quoted_cmdsubs, ¶n_offsets, c) { if !self.accept_unfinished { return self.call_error( diff --git a/fish-rust/src/wildcard.rs b/fish-rust/src/wildcard.rs index 1f731950b..25bd52928 100644 --- a/fish-rust/src/wildcard.rs +++ b/fish-rust/src/wildcard.rs @@ -852,7 +852,7 @@ fn expand_literal_intermediate_segment_with_fuzz( // TODO: justify this, tests do not exercise it yet. if m.rank() > c.r#match.rank() { // Our match is fuzzier. - c.r#match = m.clone(); + c.r#match = m; } } }