From 060c13dd8dea8774e3f7e8d5a1e5be4d3c70abcf Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Fri, 4 Mar 2022 11:21:42 -0800 Subject: [PATCH] clippy fix --- .../ast-passes/src/canonicalization/canonicalizer.rs | 10 ++++------ compiler/parser/src/tokenizer/mod.rs | 2 +- tests/test-framework/src/fetch.rs | 2 +- tests/test-framework/src/runner.rs | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/compiler/ast-passes/src/canonicalization/canonicalizer.rs b/compiler/ast-passes/src/canonicalization/canonicalizer.rs index 4c42d32407..592107d434 100644 --- a/compiler/ast-passes/src/canonicalization/canonicalizer.rs +++ b/compiler/ast-passes/src/canonicalization/canonicalizer.rs @@ -550,9 +550,7 @@ impl ReconstructingReducer for Canonicalizer { for (index, character) in string.iter().enumerate() { let col_start = span.col_start + index + 1 + col_adder; // account for open quote let bytes = span.content.clone().into_bytes(); - let col_stop: usize; - - if bytes[col_start - 1] == b'\\' { + let col_stop = if bytes[col_start - 1] == b'\\' { let mut width = 0; match bytes[col_start] { @@ -569,10 +567,10 @@ impl ReconstructingReducer for Canonicalizer { _ => width += 1, } col_adder += width; - col_stop = col_start + 1 + width; + col_start + 1 + width } else { - col_stop = col_start + 1; - } + col_start + 1 + }; elements.push(SpreadOrExpression::Expression(Expression::Value( ValueExpression::Char(CharValue { diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index f48b3222e4..81d674b0b1 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -56,7 +56,7 @@ pub(crate) fn tokenize(path: &str, input: StrTendril) -> Result>(path: T, out: &mut Vec<(String, String)>) { if entry.is_dir() { find_tests(entry.as_path(), out); continue; - } else if entry.extension().map(|x| x.to_str()).flatten().unwrap_or_default() != "leo" { + } else if entry.extension().and_then(|x| x.to_str()).unwrap_or_default() != "leo" { continue; } let content = fs::read_to_string(entry.as_path()).expect("failed to read test"); diff --git a/tests/test-framework/src/runner.rs b/tests/test-framework/src/runner.rs index b2d49394c3..3865e2a2e3 100644 --- a/tests/test-framework/src/runner.rs +++ b/tests/test-framework/src/runner.rs @@ -147,7 +147,7 @@ pub fn run_tests(runner: &T, expectation_category: &str) { let mut expected_output = expectations.as_ref().map(|x| x.outputs.iter()); for (i, test) in tests.into_iter().enumerate() { - let expected_output = expected_output.as_mut().map(|x| x.next()).flatten().cloned(); + let expected_output = expected_output.as_mut().and_then(|x| x.next()).cloned(); println!("running test {} @ '{}'", test_name, path.to_str().unwrap()); let output = namespace.run_test(Test { name: test_name.clone(),