mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
auto clippy fixes
This commit is contained in:
parent
72c85efc83
commit
ef39bad7c6
146 changed files with 750 additions and 1005 deletions
|
@ -96,10 +96,10 @@ impl<'a> Output<'a> {
|
|||
|
||||
pub fn debug_format_inner(&self) -> String {
|
||||
match self {
|
||||
Output::Header(header) => format!("{:#?}\n", header),
|
||||
Output::ModuleDefs(defs) => format!("{:#?}\n", defs),
|
||||
Output::Expr(expr) => format!("{:#?}\n", expr),
|
||||
Output::Full { .. } => format!("{:#?}\n", self),
|
||||
Output::Header(header) => format!("{header:#?}\n"),
|
||||
Output::ModuleDefs(defs) => format!("{defs:#?}\n"),
|
||||
Output::Expr(expr) => format!("{expr:#?}\n"),
|
||||
Output::Full { .. } => format!("{self:#?}\n"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ impl<'a> Input<'a> {
|
|||
// the PartialEq implementation is returning `false` even when the Debug-formatted impl is exactly the same.
|
||||
// I don't have the patience to debug this right now, so let's leave it for another day...
|
||||
// TODO: fix PartialEq impl on ast types
|
||||
if format!("{:?}", ast_normalized) != format!("{:?}", reparsed_ast_normalized) {
|
||||
if format!("{ast_normalized:?}") != format!("{reparsed_ast_normalized:?}") {
|
||||
panic!(
|
||||
"Formatting bug; formatting didn't reparse to the same AST (after removing spaces)\n\n\
|
||||
* * * Source code before formatting:\n{}\n\n\
|
||||
|
|
|
@ -43,8 +43,7 @@ mod test_fmt {
|
|||
fmt_defs(buf, &loc_defs, 0);
|
||||
}
|
||||
Err(error) => panic!(
|
||||
r"Unexpected parse failure when parsing this for defs formatting:\n\n{:?}\n\nParse error was:\n\n{:?}\n\n",
|
||||
src, error
|
||||
r"Unexpected parse failure when parsing this for defs formatting:\n\n{src:?}\n\nParse error was:\n\n{error:?}\n\n"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -67,8 +66,7 @@ mod test_fmt {
|
|||
|
||||
let (reparsed_ast, state) = module::parse_header(&arena, State::new(output.as_bytes())).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"After formatting, the source code no longer parsed!\n\nParse error was: {:?}\n\nThe code that failed to parse:\n\n{}\n\n",
|
||||
err, output
|
||||
"After formatting, the source code no longer parsed!\n\nParse error was: {err:?}\n\nThe code that failed to parse:\n\n{output}\n\n"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -80,13 +78,11 @@ mod test_fmt {
|
|||
// the PartialEq implementation is returning `false` even when the Debug-formatted impl is exactly the same.
|
||||
// I don't have the patience to debug this right now, so let's leave it for another day...
|
||||
// TODO: fix PartialEq impl on ast types
|
||||
if format!("{:?}", ast_normalized) != format!("{:?}", reparsed_ast_normalized) {
|
||||
if format!("{ast_normalized:?}") != format!("{reparsed_ast_normalized:?}") {
|
||||
panic!(
|
||||
"Formatting bug; formatting didn't reparse to the same AST (after removing spaces)\n\n\
|
||||
* * * Source code before formatting:\n{}\n\n\
|
||||
* * * Source code after formatting:\n{}\n\n",
|
||||
src,
|
||||
output
|
||||
* * * Source code before formatting:\n{src}\n\n\
|
||||
* * * Source code after formatting:\n{output}\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -111,7 +107,7 @@ mod test_fmt {
|
|||
// those more than we want to know that the expectation failed!
|
||||
assert_multiline_str_eq!(expected, output);
|
||||
}
|
||||
Err(error) => panic!("Unexpected parse failure when parsing this for module header formatting:\n\n{:?}\n\nParse error was:\n\n{:?}\n\n", src, error)
|
||||
Err(error) => panic!("Unexpected parse failure when parsing this for module header formatting:\n\n{src:?}\n\nParse error was:\n\n{error:?}\n\n")
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -526,14 +526,13 @@ mod test_snapshots {
|
|||
// Expect file to be missing
|
||||
assert!(
|
||||
!result_path.exists(),
|
||||
"Expected {:?} to be missing. \
|
||||
"Expected {result_path:?} to be missing. \
|
||||
This is how we represent a 'default' result (i.e. a test that \
|
||||
formats to the same thing as the input). \
|
||||
Consider running the tests with:\n\
|
||||
`env ROC_SNAPSHOT_TEST_OVERWRITE=1 cargo test ...`\n\
|
||||
(which will delete the file for you),\n\
|
||||
and commiting the delete.",
|
||||
result_path
|
||||
and commiting the delete."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -545,15 +544,12 @@ mod test_snapshots {
|
|||
let mut parent = std::path::PathBuf::from("tests");
|
||||
parent.push("snapshots");
|
||||
parent.push(expect.to_dir_name());
|
||||
let input_path = parent.join(format!("{}.{}.roc", name, ty));
|
||||
let result_path = parent.join(format!("{}.{}.result-ast", name, ty));
|
||||
let formatted_path = parent.join(format!("{}.{}.formatted.roc", name, ty));
|
||||
let input_path = parent.join(format!("{name}.{ty}.roc"));
|
||||
let result_path = parent.join(format!("{name}.{ty}.result-ast"));
|
||||
let formatted_path = parent.join(format!("{name}.{ty}.formatted.roc"));
|
||||
|
||||
let source = std::fs::read_to_string(&input_path).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Could not find a snapshot test result at {:?} - {:?}",
|
||||
input_path, err
|
||||
)
|
||||
panic!("Could not find a snapshot test result at {input_path:?} - {err:?}")
|
||||
});
|
||||
|
||||
let input = func(&source);
|
||||
|
@ -566,14 +562,14 @@ mod test_snapshots {
|
|||
}
|
||||
Ok(ast.debug_format_inner())
|
||||
}
|
||||
Err(err) => Err(format!("{:?}", err)),
|
||||
Err(err) => Err(format!("{err:?}")),
|
||||
};
|
||||
|
||||
if expect == TestExpectation::Pass {
|
||||
let tokens = roc_parse::highlight::highlight(&source);
|
||||
for token in tokens {
|
||||
if token.value == roc_parse::highlight::Token::Error {
|
||||
panic!("Found an error highlight token in the input: {:?}", token);
|
||||
panic!("Found an error highlight token in the input: {token:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +649,7 @@ mod test_snapshots {
|
|||
#[test]
|
||||
fn string_with_escaped_char_at_end() {
|
||||
parses_with_escaped_char(
|
||||
|esc| format!(r#""abcd{}""#, esc),
|
||||
|esc| format!(r#""abcd{esc}""#),
|
||||
|esc, arena| bumpalo::vec![in arena; Plaintext("abcd"), EscapedChar(esc)],
|
||||
);
|
||||
}
|
||||
|
@ -661,7 +657,7 @@ mod test_snapshots {
|
|||
#[test]
|
||||
fn string_with_escaped_char_in_front() {
|
||||
parses_with_escaped_char(
|
||||
|esc| format!(r#""{}abcd""#, esc),
|
||||
|esc| format!(r#""{esc}abcd""#),
|
||||
|esc, arena| bumpalo::vec![in arena; EscapedChar(esc), Plaintext("abcd")],
|
||||
);
|
||||
}
|
||||
|
@ -669,7 +665,7 @@ mod test_snapshots {
|
|||
#[test]
|
||||
fn string_with_escaped_char_in_middle() {
|
||||
parses_with_escaped_char(
|
||||
|esc| format!(r#""ab{}cd""#, esc),
|
||||
|esc| format!(r#""ab{esc}cd""#),
|
||||
|esc, arena| bumpalo::vec![in arena; Plaintext("ab"), EscapedChar(esc), Plaintext("cd")],
|
||||
);
|
||||
}
|
||||
|
@ -677,7 +673,7 @@ mod test_snapshots {
|
|||
#[test]
|
||||
fn string_with_multiple_escaped_chars() {
|
||||
parses_with_escaped_char(
|
||||
|esc| format!(r#""{}abc{}de{}fghi{}""#, esc, esc, esc, esc),
|
||||
|esc| format!(r#""{esc}abc{esc}de{esc}fghi{esc}""#),
|
||||
|esc, arena| bumpalo::vec![in arena; EscapedChar(esc), Plaintext("abc"), EscapedChar(esc), Plaintext("de"), EscapedChar(esc), Plaintext("fghi"), EscapedChar(esc)],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue