diff --git a/compiler/parser/examples/input_parser.rs b/compiler/parser/examples/input_parser.rs index 6cc6661bcd..23da6f59e6 100644 --- a/compiler/parser/examples/input_parser.rs +++ b/compiler/parser/examples/input_parser.rs @@ -48,8 +48,8 @@ fn main() -> Result<(), String> { let input_tree = create_session_if_not_set_then(|_| { Handler::with(|handler| { let input = - leo_parser::parse_program_inputs(&handler, input_string.clone(), opt.input_path.to_str().unwrap())?; - Ok(input.to_json_string()?) + leo_parser::parse_program_inputs(handler, input_string.clone(), opt.input_path.to_str().unwrap())?; + input.to_json_string() }) .map_err(|e| e.to_string()) })?; diff --git a/compiler/parser/examples/parser.rs b/compiler/parser/examples/parser.rs index 3f040aba69..d9757a04f9 100644 --- a/compiler/parser/examples/parser.rs +++ b/compiler/parser/examples/parser.rs @@ -47,7 +47,7 @@ fn main() -> Result<(), String> { // Parses the Leo file constructing an ast which is then serialized. let serialized_leo_tree = create_session_if_not_set_then(|_| { Handler::with(|h| { - let ast = leo_parser::parse_ast(&h, opt.input_path.to_str().unwrap(), &code)?; + let ast = leo_parser::parse_ast(h, opt.input_path.to_str().unwrap(), &code)?; let json = Ast::to_json_string(&ast)?; println!("{}", json); Ok(json) diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index 91d1082de4..5cee96b54d 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -221,29 +221,27 @@ impl<'a> ParserContext<'a> { } let second = self.peek_group_coordinate(&mut i)?; - let right_paren_span; i = i.checked_sub(1)?; - if let Some(SpannedToken { + let right_paren_span = if let Some(SpannedToken { token: Token::RightParen, span, }) = self.tokens.get(i) { - right_paren_span = span.clone(); + span.clone() } else { return None; - } + }; - let end_span; i = i.checked_sub(1)?; - if let Some(SpannedToken { + let end_span = if let Some(SpannedToken { token: Token::Group, span, }) = self.tokens.get(i) { - end_span = span.clone(); + span.clone() } else { return None; - } + }; self.tokens.drain(i..); if let Err(e) = assert_no_whitespace( diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index b8c3c331c5..337e19368a 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -422,7 +422,7 @@ impl Token { eol + 4 } else { return Err(ParserError::lexer_block_comment_does_not_close_before_eof( - String::from_utf8_lossy(&input), + String::from_utf8_lossy(input), ) .into()); }; @@ -515,7 +515,7 @@ impl Token { )); } - Err(ParserError::could_not_lex(String::from_utf8_lossy(&input)).into()) + Err(ParserError::could_not_lex(String::from_utf8_lossy(input)).into()) } } diff --git a/leo/package/src/root/manifest.rs b/leo/package/src/root/manifest.rs index ca9d78a8bf..62df3e5f68 100644 --- a/leo/package/src/root/manifest.rs +++ b/leo/package/src/root/manifest.rs @@ -238,8 +238,8 @@ impl TryFrom<&Path> for Manifest { // Fetch the author from the old remote. let remote_author = old_remote .split('/') // Split the old remote as '"{author}' and '{package_name}"' - .nth(0).unwrap() // Fetch just the '"{author}' - .replace(&['\"', ' '], ""); // Remove the quotes from the author string + .next().unwrap() // Fetch just the '"{author}' + .replace(['\"', ' '].as_slice(), ""); // Remove the quotes from the author string // Construct the new remote section. let new_remote = format!( diff --git a/leo/span/src/tendril_json.rs b/leo/span/src/tendril_json.rs index 9a788e56a3..5f2194ab4c 100644 --- a/leo/span/src/tendril_json.rs +++ b/leo/span/src/tendril_json.rs @@ -21,7 +21,7 @@ use tendril::StrTendril; /// Serialization for the StrTendril type. pub fn serialize(tendril: &StrTendril, serializer: S) -> Result { - serializer.serialize_str(&tendril) + serializer.serialize_str(tendril) } /// Deserialization for the StrTendril type. diff --git a/tests/test-framework/src/runner.rs b/tests/test-framework/src/runner.rs index 522a33a34b..cae20affc7 100644 --- a/tests/test-framework/src/runner.rs +++ b/tests/test-framework/src/runner.rs @@ -70,14 +70,7 @@ fn take_hook( output: Result, Box>, panic_buf: Arc>>, ) -> Result, String> { - output.map_err(|_| { - panic_buf - .lock() - .unwrap() - .take() - .expect("failed to get panic message") - .clone() - }) + output.map_err(|_| panic_buf.lock().unwrap().take().expect("failed to get panic message")) } pub fn run_tests(runner: &T, expectation_category: &str) {