Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to rust 1.67 #5345

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/windows_release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: zig version
run: zig version

- name: install rust nightly 1.66
run: rustup install nightly-2022-10-30
- name: install rust nightly 1.67
run: rustup install nightly-2022-12-09

- name: set up llvm 13
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: zig version
run: zig version

- name: install rust nightly 1.66
run: rustup install nightly-2022-10-30
- name: install rust nightly 1.67
run: rustup install nightly-2022-12-09

- name: set up llvm 13
run: |
Expand Down
4 changes: 2 additions & 2 deletions crates/ast/src/ast_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ impl From<ModuleError> for ASTError {
impl From<(Region, Loc<Ident>)> for ASTError {
fn from(ident_exists_err: (Region, Loc<Ident>)) -> Self {
Self::IdentExistsError {
msg: format!("{:?}", ident_exists_err),
msg: format!("{ident_exists_err:?}"),
}
}
}

impl<'a> From<SyntaxError<'a>> for ASTError {
fn from(syntax_err: SyntaxError) -> Self {
Self::SyntaxErrorNoBacktrace {
msg: format!("{:?}", syntax_err),
msg: format!("{syntax_err:?}"),
}
}
}
3 changes: 1 addition & 2 deletions crates/ast/src/builtin_aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ pub fn aliases() -> MutMap<Symbol, BuiltinAlias> {
let mut add_alias = |symbol, alias| {
debug_assert!(
!aliases.contains_key(&symbol),
"Duplicate alias definition for {:?}",
symbol
"Duplicate alias definition for {symbol:?}"
);

// TODO instead of using Region::zero for all of these,
Expand Down
2 changes: 1 addition & 1 deletion crates/ast/src/constrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ pub mod test_constrain {

assert_eq!(actual_str, expected_str);
}
Err(e) => panic!("syntax error {:?}", e),
Err(e) => panic!("syntax error {e:?}"),
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/ast/src/lang/core/expr/expr2_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn expr2_to_string_helper(
);
}
Expr2::Call { .. } => {
let _ = write!(out_string, "Call({:?})", expr2);
let _ = write!(out_string, "Call({expr2:?})");
}
Expr2::Closure { args, .. } => {
out_string.push_str("Closure:\n");
Expand All @@ -148,7 +148,7 @@ fn expr2_to_string_helper(
}
}
&Expr2::Var { .. } => {
let _ = write!(out_string, "{:?}", expr2);
let _ = write!(out_string, "{expr2:?}");
}
Expr2::RuntimeError { .. } => {
out_string.push_str("RuntimeError\n");
Expand Down
16 changes: 4 additions & 12 deletions crates/ast/src/lang/core/expr/expr_to_expr2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,27 +671,19 @@ pub fn expr_to_expr2<'a>(
// operator desugaring should have removed them!
bad_expr @ SpaceBefore(_, _) => {
panic!(
"A SpaceBefore did not get removed during operator desugaring somehow: {:#?}",
bad_expr
"A SpaceBefore did not get removed during operator desugaring somehow: {bad_expr:#?}"
);
}
bad_expr @ SpaceAfter(_, _) => {
panic!(
"A SpaceAfter did not get removed during operator desugaring somehow: {:#?}",
bad_expr
"A SpaceAfter did not get removed during operator desugaring somehow: {bad_expr:#?}"
);
}
bad_expr @ BinOps { .. } => {
panic!(
"A binary operator chain did not get desugared somehow: {:#?}",
bad_expr
);
panic!("A binary operator chain did not get desugared somehow: {bad_expr:#?}");
}
bad_expr @ UnaryOp(_, _) => {
panic!(
"A unary operator did not get desugared somehow: {:#?}",
bad_expr
);
panic!("A unary operator did not get desugared somehow: {bad_expr:#?}");
}

rest => todo!("not yet implemented {:?}", rest),
Expand Down
2 changes: 1 addition & 1 deletion crates/ast/src/lang/core/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub fn update_str_expr(
Expr2::Str(old_pool_str) => Either::OldPoolStr(*old_pool_str),
other => UnexpectedASTNodeSnafu {
required_node_type: "SmallStr or Str",
encountered_node_type: format!("{:?}", other),
encountered_node_type: format!("{other:?}"),
}
.fail()?,
};
Expand Down
3 changes: 1 addition & 2 deletions crates/ast/src/lang/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ impl<'a> Env<'a> {
) -> Result<Symbol, RuntimeError> {
debug_assert!(
!module_name.is_empty(),
"Called env.qualified_lookup with an unqualified ident: {:?}",
ident
"Called env.qualified_lookup with an unqualified ident: {ident:?}"
);

let module_name: ModuleName = module_name.into();
Expand Down
10 changes: 2 additions & 8 deletions crates/ast/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ pub fn load_module(
match loaded {
Ok(x) => x,
Err(roc_load::LoadingProblem::FormattedReport(report)) => {
panic!(
"Failed to load module from src_file: {:?}. Report: {}",
src_file, report
);
panic!("Failed to load module from src_file: {src_file:?}. Report: {report}");
}
Err(e) => panic!(
"Failed to load module from src_file {:?}: {:?}",
src_file, e
),
Err(e) => panic!("Failed to load module from src_file {src_file:?}: {e:?}"),
}
}
6 changes: 3 additions & 3 deletions crates/cli/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
20 changes: 7 additions & 13 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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?"
));
}
}
Expand Down Expand Up @@ -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)?;

Expand Down Expand Up @@ -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}")),
}
}
}
6 changes: 3 additions & 3 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
}
}
}
Expand Down Expand Up @@ -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
}
};
Expand Down
22 changes: 9 additions & 13 deletions crates/cli/tests/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod cli_run {

// e.g. "1 error and 0 warnings found in 123 ms."
let (before_first_digit, _) = err.split_at(err.rfind("found in ").unwrap());
let err = format!("{}found in <ignored for test> ms.", before_first_digit);
let err = format!("{before_first_digit}found in <ignored for test> ms.");

// make paths consistent
let err = err.replace('\\', "/");
Expand Down Expand Up @@ -230,22 +230,22 @@ mod cli_run {
what: _,
xwhat,
} = error;
println!("Valgrind Error: {}\n", kind);
println!("Valgrind Error: {kind}\n");

if let Some(ValgrindErrorXWhat {
text,
leakedbytes: _,
leakedblocks: _,
}) = xwhat
{
println!(" {}", text);
println!(" {text}");
}
}
panic!("Valgrind reported memory errors");
}
} else {
let exit_code = match valgrind_out.status.code() {
Some(code) => format!("exit code {}", code),
Some(code) => format!("exit code {code}"),
None => "no exit code".to_string(),
};

Expand Down Expand Up @@ -301,7 +301,7 @@ mod cli_run {
// e.g. "1 failed and 0 passed in 123 ms."
if let Some(split) = actual.rfind("passed in ") {
let (before_first_digit, _) = actual.split_at(split);
actual = format!("{}passed in <ignored for test> ms.", before_first_digit);
actual = format!("{before_first_digit}passed in <ignored for test> ms.");
}

let self_path = file.display().to_string();
Expand Down Expand Up @@ -397,8 +397,7 @@ mod cli_run {
"swiftui" | "rocLovesSwift" => {
if cfg!(not(target_os = "macos")) {
eprintln!(
"WARNING: skipping testing example {} because it only works on MacOS.",
roc_filename
"WARNING: skipping testing example {roc_filename} because it only works on MacOS."
);
return;
} else {
Expand All @@ -409,8 +408,7 @@ mod cli_run {
"rocLovesWebAssembly" => {
// this is a web assembly example, but we don't test with JS at the moment
eprintln!(
"WARNING: skipping testing example {} because it only works in a browser!",
roc_filename
"WARNING: skipping testing example {roc_filename} because it only works in a browser!"
);
return;
}
Expand Down Expand Up @@ -965,16 +963,14 @@ mod cli_run {
match roc_filename {
"QuicksortApp.roc" => {
eprintln!(
"WARNING: skipping testing benchmark {} because the test is broken right now!",
roc_filename
"WARNING: skipping testing benchmark {roc_filename} because the test is broken right now!"
);
return;
}
"TestAStar.roc" => {
if cfg!(feature = "wasm32-cli-run") {
eprintln!(
"WARNING: skipping testing benchmark {} because it currently does not work on wasm32 due to dictionaries.",
roc_filename
"WARNING: skipping testing benchmark {roc_filename} because it currently does not work on wasm32 due to dictionaries."
);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod editor_launch_test {

// The editor expects to be run from the root of the repo, so it can find the cli-platform to init a new project folder.
env::set_current_dir(&root_dir)
.unwrap_or_else(|_| panic!("Failed to set current dir to {:?}", root_dir));
.unwrap_or_else(|_| panic!("Failed to set current dir to {root_dir:?}"));

let roc_binary_path = build_roc_bin(&["--features", "editor"]);

Expand Down
10 changes: 3 additions & 7 deletions crates/cli_utils/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ fn exec_bench_w_input<T: Measurement>(

assert!(
compile_out.status.success(),
"build ended with bad status {:?}",
compile_out
"build ended with bad status {compile_out:?}"
);

check_cmd_output(file, stdin_str, executable_filename, expected_ending);
Expand Down Expand Up @@ -58,10 +57,7 @@ fn check_cmd_output(
};

if !&out.stdout.ends_with(expected_ending) {
panic!(
"expected output to end with {:?} but instead got {:#?}",
expected_ending, out
);
panic!("expected output to end with {expected_ending:?} but instead got {out:#?}");
}
assert!(out.status.success());
}
Expand Down Expand Up @@ -96,7 +92,7 @@ fn bench_cmd<T: Measurement>(
}

if let Some(bench_group) = bench_group_opt {
bench_group.bench_function(&format!("Benchmarking {:?}", executable_filename), |b| {
bench_group.bench_function(&format!("Benchmarking {executable_filename:?}"), |b| {
b.iter(|| run_cmd(black_box(&cmd_str), black_box([stdin_str]), &[], []))
});
} else {
Expand Down
Loading