mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
auto clippy fixes
This commit is contained in:
parent
72c85efc83
commit
ef39bad7c6
146 changed files with 750 additions and 1005 deletions
|
@ -93,18 +93,18 @@ pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), Str
|
|||
// 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:?}") {
|
||||
let mut fail_file = file.clone();
|
||||
fail_file.set_extension("roc-format-failed");
|
||||
std::fs::write(&fail_file, buf.as_str()).unwrap();
|
||||
|
||||
let mut before_file = file.clone();
|
||||
before_file.set_extension("roc-format-failed-ast-before");
|
||||
std::fs::write(&before_file, format!("{:#?}\n", ast_normalized)).unwrap();
|
||||
std::fs::write(&before_file, format!("{ast_normalized:#?}\n")).unwrap();
|
||||
|
||||
let mut after_file = file.clone();
|
||||
after_file.set_extension("roc-format-failed-ast-after");
|
||||
std::fs::write(&after_file, format!("{:#?}\n", reparsed_ast_normalized)).unwrap();
|
||||
std::fs::write(&after_file, format!("{reparsed_ast_normalized:#?}\n")).unwrap();
|
||||
|
||||
internal_error!(
|
||||
"Formatting bug; formatting didn't reparse as the same tree\n\n\
|
||||
|
|
|
@ -416,12 +416,10 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
|||
match matches.value_source(ROC_FILE) {
|
||||
Some(ValueSource::DefaultValue) => {
|
||||
eprintln!(
|
||||
"\nThe current directory ({}) does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
||||
current_dir_string,
|
||||
DEFAULT_ROC_FILENAME
|
||||
"\nThe current directory ({current_dir_string}) does not contain a {DEFAULT_ROC_FILENAME} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n"
|
||||
)
|
||||
}
|
||||
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", expected_file_path_string),
|
||||
_ => eprintln!("\nThis file was not found: {expected_file_path_string}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n"),
|
||||
}
|
||||
|
||||
process::exit(1);
|
||||
|
@ -565,16 +563,13 @@ pub fn build(
|
|||
match matches.value_source(ROC_FILE) {
|
||||
Some(ValueSource::DefaultValue) => {
|
||||
eprintln!(
|
||||
"\nThe current directory ({}) does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
||||
current_dir_string,
|
||||
DEFAULT_ROC_FILENAME
|
||||
"\nThe current directory ({current_dir_string}) does not contain a {DEFAULT_ROC_FILENAME} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n"
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
let mut error_lines = Vec::new();
|
||||
error_lines.push(format!(
|
||||
"This file was not found: {}",
|
||||
expected_file_path_string
|
||||
"This file was not found: {expected_file_path_string}"
|
||||
));
|
||||
// Add some additional hints if run as `roc [FILENAME]`.
|
||||
if matches.subcommand().is_none() {
|
||||
|
@ -584,8 +579,7 @@ pub fn build(
|
|||
nearest_match(possible_typo, subcommands)
|
||||
{
|
||||
error_lines.push(format!(
|
||||
"Did you mean to use the {} subcommand?",
|
||||
nearest_command
|
||||
"Did you mean to use the {nearest_command} subcommand?"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1144,7 +1138,7 @@ fn roc_run_executable_file_path(binary_bytes: &[u8]) -> std::io::Result<Executab
|
|||
);
|
||||
}
|
||||
|
||||
let path = PathBuf::from(format!("/proc/self/fd/{}", fd));
|
||||
let path = PathBuf::from(format!("/proc/self/fd/{fd}"));
|
||||
|
||||
std::fs::write(&path, binary_bytes)?;
|
||||
|
||||
|
@ -1351,7 +1345,7 @@ impl std::str::FromStr for Target {
|
|||
"linux64" => Ok(Target::Linux64),
|
||||
"windows64" => Ok(Target::Windows64),
|
||||
"wasm32" => Ok(Target::Wasm32),
|
||||
_ => Err(format!("Roc does not know how to compile to {}", string)),
|
||||
_ => Err(format!("Roc does not know how to compile to {string}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,12 +200,12 @@ fn main() -> io::Result<()> {
|
|||
}
|
||||
|
||||
Err(LoadingProblem::FormattedReport(report)) => {
|
||||
print!("{}", report);
|
||||
print!("{report}");
|
||||
|
||||
Ok(1)
|
||||
}
|
||||
Err(other) => {
|
||||
panic!("build_file failed with error:\n{:?}", other);
|
||||
panic!("build_file failed with error:\n{other:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ fn main() -> io::Result<()> {
|
|||
let format_exit_code = match format(roc_files, format_mode) {
|
||||
Ok(_) => 0,
|
||||
Err(message) => {
|
||||
eprintln!("{}", message);
|
||||
eprintln!("{message}");
|
||||
1
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue