clippy fix

This commit is contained in:
gluax 2022-03-04 11:21:42 -08:00
parent 789862103e
commit 060c13dd8d
4 changed files with 7 additions and 9 deletions

View File

@ -550,9 +550,7 @@ impl ReconstructingReducer for Canonicalizer {
for (index, character) in string.iter().enumerate() { for (index, character) in string.iter().enumerate() {
let col_start = span.col_start + index + 1 + col_adder; // account for open quote let col_start = span.col_start + index + 1 + col_adder; // account for open quote
let bytes = span.content.clone().into_bytes(); let bytes = span.content.clone().into_bytes();
let col_stop: usize; let col_stop = if bytes[col_start - 1] == b'\\' {
if bytes[col_start - 1] == b'\\' {
let mut width = 0; let mut width = 0;
match bytes[col_start] { match bytes[col_start] {
@ -569,10 +567,10 @@ impl ReconstructingReducer for Canonicalizer {
_ => width += 1, _ => width += 1,
} }
col_adder += width; col_adder += width;
col_stop = col_start + 1 + width; col_start + 1 + width
} else { } else {
col_stop = col_start + 1; col_start + 1
} };
elements.push(SpreadOrExpression::Expression(Expression::Value( elements.push(SpreadOrExpression::Expression(Expression::Value(
ValueExpression::Char(CharValue { ValueExpression::Char(CharValue {

View File

@ -56,7 +56,7 @@ pub(crate) fn tokenize(path: &str, input: StrTendril) -> Result<Vec<SpannedToken
path, path,
input.subtendril( input.subtendril(
line_start as u32, line_start as u32,
input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32, input[line_start..].find('\n').unwrap_or(input.len()) as u32,
), ),
), ),
) )

View File

@ -22,7 +22,7 @@ pub fn find_tests<T: AsRef<Path>>(path: T, out: &mut Vec<(String, String)>) {
if entry.is_dir() { if entry.is_dir() {
find_tests(entry.as_path(), out); find_tests(entry.as_path(), out);
continue; 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; continue;
} }
let content = fs::read_to_string(entry.as_path()).expect("failed to read test"); let content = fs::read_to_string(entry.as_path()).expect("failed to read test");

View File

@ -147,7 +147,7 @@ pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {
let mut expected_output = expectations.as_ref().map(|x| x.outputs.iter()); let mut expected_output = expectations.as_ref().map(|x| x.outputs.iter());
for (i, test) in tests.into_iter().enumerate() { 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()); println!("running test {} @ '{}'", test_name, path.to_str().unwrap());
let output = namespace.run_test(Test { let output = namespace.run_test(Test {
name: test_name.clone(), name: test_name.clone(),