mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
1.62.1 version update, fmt, clippy
This commit is contained in:
parent
e71b657662
commit
9aee7cdcf6
9 changed files with 107 additions and 80 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM rust:1.61.0-slim-bullseye # make sure to update rust-toolchain.toml too so that everything uses the same rust version
|
||||
FROM rust:1.62.1-slim-bullseye # make sure to update rust-toolchain.toml too so that everything uses the same rust version
|
||||
WORKDIR /earthbuild
|
||||
|
||||
prep-debian:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use roc_module::symbol::IdentId;
|
||||
use std::fmt::Write as _; // import without risk of name clashing
|
||||
|
||||
use crate::{
|
||||
lang::core::expr::{expr2::Expr2, expr2_to_string::expr2_to_string},
|
||||
|
@ -35,11 +36,12 @@ pub fn def2_to_string(node_id: DefId, pool: &Pool) -> String {
|
|||
identifier_id,
|
||||
expr_id,
|
||||
} => {
|
||||
full_string.push_str(&format!(
|
||||
let _ = write!(
|
||||
full_string,
|
||||
"Def2::ValueDef(identifier_id: >>{:?}), expr_id: >>{:?})",
|
||||
identifier_id,
|
||||
expr2_to_string(*expr_id, pool)
|
||||
));
|
||||
);
|
||||
}
|
||||
Def2::Blank => {
|
||||
full_string.push_str("Def2::Blank");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::expr2::{Expr2, ExprId};
|
||||
use crate::{
|
||||
lang::core::{expr::record_field::RecordField, val_def::value_def_to_string},
|
||||
mem_pool::pool::Pool,
|
||||
};
|
||||
|
||||
use super::expr2::{Expr2, ExprId};
|
||||
use roc_types::subs::Variable;
|
||||
use std::fmt::Write as _; // import without risk of name clashing
|
||||
|
||||
pub fn expr2_to_string(node_id: ExprId, pool: &Pool) -> String {
|
||||
let mut full_string = String::new();
|
||||
|
@ -31,14 +31,11 @@ fn expr2_to_string_helper(
|
|||
out_string.push_str(&get_spacing(indent_level));
|
||||
|
||||
match expr2 {
|
||||
Expr2::SmallStr(arr_string) => out_string.push_str(&format!(
|
||||
"{}{}{}",
|
||||
"SmallStr(\"",
|
||||
arr_string.as_str(),
|
||||
"\")",
|
||||
)),
|
||||
Expr2::SmallStr(arr_string) => {
|
||||
let _ = write!(out_string, "SmallStr(\"{}\"", arr_string.as_str(),);
|
||||
}
|
||||
Expr2::Str(pool_str) => {
|
||||
out_string.push_str(&format!("{}{}{}", "Str(\"", pool_str.as_str(pool), "\")",))
|
||||
let _ = write!(out_string, "Str(\"{}\")", pool_str.as_str(pool));
|
||||
}
|
||||
Expr2::Blank => out_string.push_str("Blank"),
|
||||
Expr2::EmptyRecord => out_string.push_str("EmptyRecord"),
|
||||
|
@ -46,7 +43,7 @@ fn expr2_to_string_helper(
|
|||
out_string.push_str("Record:\n");
|
||||
out_string.push_str(&var_to_string(record_var, indent_level + 1));
|
||||
|
||||
out_string.push_str(&format!("{}fields: [\n", get_spacing(indent_level + 1)));
|
||||
let _ = writeln!(out_string, "{}fields: [", get_spacing(indent_level + 1));
|
||||
|
||||
let mut first_child = true;
|
||||
|
||||
|
@ -59,43 +56,46 @@ fn expr2_to_string_helper(
|
|||
|
||||
match field {
|
||||
RecordField::InvalidLabelOnly(pool_str, var) => {
|
||||
out_string.push_str(&format!(
|
||||
let _ = write!(
|
||||
out_string,
|
||||
"{}({}, Var({:?})",
|
||||
get_spacing(indent_level + 2),
|
||||
pool_str.as_str(pool),
|
||||
var,
|
||||
));
|
||||
);
|
||||
}
|
||||
RecordField::LabelOnly(pool_str, var, symbol) => {
|
||||
out_string.push_str(&format!(
|
||||
let _ = write!(
|
||||
out_string,
|
||||
"{}({}, Var({:?}), Symbol({:?})",
|
||||
get_spacing(indent_level + 2),
|
||||
pool_str.as_str(pool),
|
||||
var,
|
||||
symbol
|
||||
));
|
||||
);
|
||||
}
|
||||
RecordField::LabeledValue(pool_str, var, val_node_id) => {
|
||||
out_string.push_str(&format!(
|
||||
"{}({}, Var({:?}), Expr2(\n",
|
||||
let _ = writeln!(
|
||||
out_string,
|
||||
"{}({}, Var({:?}), Expr2(",
|
||||
get_spacing(indent_level + 2),
|
||||
pool_str.as_str(pool),
|
||||
var,
|
||||
));
|
||||
);
|
||||
|
||||
let val_expr2 = pool.get(*val_node_id);
|
||||
expr2_to_string_helper(val_expr2, indent_level + 3, pool, out_string);
|
||||
out_string.push_str(&format!("{})\n", get_spacing(indent_level + 2)));
|
||||
let _ = writeln!(out_string, "{})", get_spacing(indent_level + 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out_string.push_str(&format!("{}]\n", get_spacing(indent_level + 1)));
|
||||
let _ = writeln!(out_string, "{}]", get_spacing(indent_level + 1));
|
||||
}
|
||||
Expr2::List { elem_var, elems } => {
|
||||
out_string.push_str("List:\n");
|
||||
out_string.push_str(&var_to_string(elem_var, indent_level + 1));
|
||||
out_string.push_str(&format!("{}elems: [\n", get_spacing(indent_level + 1)));
|
||||
let _ = writeln!(out_string, "{}elems: [\n", get_spacing(indent_level + 1));
|
||||
|
||||
let mut first_elt = true;
|
||||
|
||||
|
@ -111,42 +111,44 @@ fn expr2_to_string_helper(
|
|||
expr2_to_string_helper(elem_expr2, indent_level + 2, pool, out_string)
|
||||
}
|
||||
|
||||
out_string.push_str(&format!("{}]\n", get_spacing(indent_level + 1)));
|
||||
let _ = writeln!(out_string, "{}]", get_spacing(indent_level + 1));
|
||||
}
|
||||
Expr2::InvalidLookup(pool_str) => {
|
||||
out_string.push_str(&format!("InvalidLookup({})", pool_str.as_str(pool)));
|
||||
let _ = write!(out_string, "InvalidLookup({})", pool_str.as_str(pool));
|
||||
}
|
||||
Expr2::SmallInt { text, .. } => {
|
||||
out_string.push_str(&format!("SmallInt({})", text.as_str(pool)));
|
||||
let _ = write!(out_string, "SmallInt({})", text.as_str(pool));
|
||||
}
|
||||
Expr2::LetValue {
|
||||
def_id, body_id, ..
|
||||
} => {
|
||||
out_string.push_str(&format!(
|
||||
let _ = write!(
|
||||
out_string,
|
||||
"LetValue(def_id: >>{:?}), body_id: >>{:?})",
|
||||
value_def_to_string(pool.get(*def_id), pool),
|
||||
pool.get(*body_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
Expr2::Call { .. } => {
|
||||
out_string.push_str(&format!("Call({:?})", expr2,));
|
||||
let _ = write!(out_string, "Call({:?})", expr2);
|
||||
}
|
||||
Expr2::Closure { args, .. } => {
|
||||
out_string.push_str("Closure:\n");
|
||||
out_string.push_str(&format!("{}args: [\n", get_spacing(indent_level + 1)));
|
||||
let _ = writeln!(out_string, "{}args: [", get_spacing(indent_level + 1));
|
||||
|
||||
for (_, pattern_id) in args.iter(pool) {
|
||||
let arg_pattern2 = pool.get(*pattern_id);
|
||||
|
||||
out_string.push_str(&format!(
|
||||
"{}{:?}\n",
|
||||
let _ = writeln!(
|
||||
out_string,
|
||||
"{}{:?}",
|
||||
get_spacing(indent_level + 2),
|
||||
arg_pattern2
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
&Expr2::Var { .. } => {
|
||||
out_string.push_str(&format!("{:?}", expr2,));
|
||||
let _ = write!(out_string, "{:?}", expr2);
|
||||
}
|
||||
Expr2::RuntimeError { .. } => {
|
||||
out_string.push_str("RuntimeError\n");
|
||||
|
|
|
@ -19,7 +19,7 @@ macro_rules! disassembler_test {
|
|||
// TODO: Not sure if there is a better way to merge these together,
|
||||
// but I like the end use of this a lot better than the old tests.
|
||||
($assemble_fn: expr, $format_fn: expr) => {{
|
||||
use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
let arena = bumpalo::Bump::new();
|
||||
let (mut buf, cs) = setup_capstone_and_arena(&arena);
|
||||
$assemble_fn(&mut buf);
|
||||
|
@ -30,7 +30,7 @@ macro_rules! disassembler_test {
|
|||
);
|
||||
}};
|
||||
($assemble_fn: expr, $format_fn: expr, $iter:expr) => {{
|
||||
use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
let arena = bumpalo::Bump::new();
|
||||
let (mut buf, cs) = setup_capstone_and_arena(&arena);
|
||||
for i in $iter.iter() {
|
||||
|
@ -44,7 +44,7 @@ macro_rules! disassembler_test {
|
|||
}
|
||||
}};
|
||||
($assemble_fn: expr, $format_fn: expr, $iter:expr, $iter2:expr) => {{
|
||||
use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
let arena = bumpalo::Bump::new();
|
||||
let (mut buf, cs) = setup_capstone_and_arena(&arena);
|
||||
for i in $iter.iter() {
|
||||
|
@ -60,7 +60,7 @@ macro_rules! disassembler_test {
|
|||
}
|
||||
}};
|
||||
($assemble_fn: expr, $format_fn: expr, $iter:expr, $iter2:expr, $iter3:expr) => {{
|
||||
use crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
use $crate::generic64::disassembler_test_macro::merge_instructions_without_line_numbers;
|
||||
let arena = bumpalo::Bump::new();
|
||||
let (mut buf, cs) = setup_capstone_and_arena(&arena);
|
||||
for i in $iter.iter() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::path::PathBuf;
|
||||
use std::fmt::Write as _;
|
||||
use std::path::PathBuf; // import without risk of name clashing
|
||||
|
||||
use bumpalo::Bump;
|
||||
use ven_pretty::DocAllocator;
|
||||
|
@ -249,20 +250,21 @@ fn assemble_derived_golden(
|
|||
|
||||
let mut pretty_buf = String::new();
|
||||
|
||||
pretty_buf.push_str(&format!("# derived for {}\n", print_var(source_var, false)));
|
||||
// ignore returned result, writeln can not fail as it is used here
|
||||
let _ = writeln!(pretty_buf, "# derived for {}", print_var(source_var, false));
|
||||
|
||||
let pretty_type = print_var(typ, false);
|
||||
pretty_buf.push_str(&format!("# {}\n", &pretty_type));
|
||||
let _ = writeln!(pretty_buf, "# {}", &pretty_type);
|
||||
|
||||
let pretty_type_under_aliases = print_var(typ, true);
|
||||
pretty_buf.push_str(&format!("# {}\n", &pretty_type_under_aliases));
|
||||
let _ = writeln!(pretty_buf, "# {}", &pretty_type_under_aliases);
|
||||
|
||||
pretty_buf.push_str("# Specialization lambda sets:\n");
|
||||
let mut specialization_lsets = specialization_lsets.into_iter().collect::<Vec<_>>();
|
||||
specialization_lsets.sort_by_key(|(region, _)| *region);
|
||||
for (region, var) in specialization_lsets {
|
||||
let pretty_lset = print_var(var, false);
|
||||
pretty_buf.push_str(&format!("# @<{}>: {}\n", region, pretty_lset));
|
||||
let _ = writeln!(pretty_buf, "# @<{}>: {}", region, pretty_lset);
|
||||
}
|
||||
|
||||
pretty_buf.push_str(derived_source);
|
||||
|
|
|
@ -341,7 +341,8 @@ fn add_single_tag_struct(
|
|||
let field_type = type_name(*field_id, types);
|
||||
|
||||
// These are all private fields, since this is a tag union.
|
||||
body.push_str(&format!("{INDENT}f{index}: {field_type},\n"));
|
||||
// ignore returned result, writeln can not fail as it is used here
|
||||
let _ = writeln!(body, "{INDENT}f{index}: {field_type},");
|
||||
}
|
||||
|
||||
body.push_str("}\n");
|
||||
|
@ -457,19 +458,22 @@ fn add_single_tag_struct(
|
|||
"fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {".to_string();
|
||||
|
||||
if payload_fields.is_empty() {
|
||||
buf.push_str(&format!("f.write_str(\"{name}::{tag_name}\")"));
|
||||
// ignore returned result, write can not fail as it is used here
|
||||
let _ = write!(buf, "f.write_str(\"{name}::{tag_name}\")");
|
||||
} else {
|
||||
buf.push_str(&format!(
|
||||
let _ = write!(
|
||||
buf,
|
||||
"\n{INDENT}{INDENT}{INDENT}f.debug_tuple(\"{name}::{tag_name}\")"
|
||||
));
|
||||
);
|
||||
|
||||
for (index, _) in payload_fields.iter().enumerate() {
|
||||
buf.push_str(&format!(
|
||||
let _ = write!(
|
||||
buf,
|
||||
"{INDENT}{INDENT}{INDENT}{INDENT}.field(&self.f{index})"
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
buf.push_str(&format!("{INDENT}{INDENT}{INDENT}{INDENT}.finish()"));
|
||||
let _ = write!(buf, "{INDENT}{INDENT}{INDENT}{INDENT}.finish()");
|
||||
}
|
||||
|
||||
buf.push_str(" }\n");
|
||||
|
@ -1113,9 +1117,10 @@ pub struct {name} {{
|
|||
|
||||
// There's only one tag, so there's no discriminant and no need to match;
|
||||
// just drop the pointer.
|
||||
drop_payload.push_str(&format!(
|
||||
let _ = write!(
|
||||
drop_payload,
|
||||
r#"unsafe {{ core::mem::ManuallyDrop::drop(&mut core::ptr::read(self.pointer).{tag_name}); }}"#
|
||||
));
|
||||
);
|
||||
} else {
|
||||
write_impl_tags(
|
||||
3,
|
||||
|
@ -1202,10 +1207,11 @@ pub struct {name} {{
|
|||
|
||||
// There's only one tag, so there's no discriminant and no need to match;
|
||||
// just return whether my payload equals the other one.
|
||||
buf.push_str(&format!(
|
||||
let _ = write!(
|
||||
buf,
|
||||
r#"{INDENT}{INDENT}{INDENT}{INDENT}(*self.pointer).{tag_name} == (*other.pointer).{tag_name}
|
||||
"#
|
||||
));
|
||||
);
|
||||
} else {
|
||||
write_impl_tags(
|
||||
3,
|
||||
|
@ -1425,12 +1431,13 @@ pub struct {name} {{
|
|||
|
||||
// There's only one tag, so there's no discriminant and no need to match;
|
||||
// just return whether my payload equals the other one.
|
||||
buf.push_str(&format!(
|
||||
let _ = write!(
|
||||
buf,
|
||||
r#"
|
||||
unsafe {{
|
||||
(*self.pointer).{tag_name}.hash(state)
|
||||
}}"#
|
||||
));
|
||||
);
|
||||
} else {
|
||||
write_impl_tags(
|
||||
2,
|
||||
|
@ -1476,11 +1483,12 @@ pub struct {name} {{
|
|||
|
||||
// There's only one tag, so there's no discriminant and no need to match;
|
||||
// just return whether my payload equals the other one.
|
||||
buf.push_str(&format!(
|
||||
let _ = write!(
|
||||
buf,
|
||||
r#"f.debug_tuple("{tag_name}")
|
||||
.field(&(*self.pointer).{tag_name})
|
||||
.finish()"#,
|
||||
));
|
||||
);
|
||||
} else {
|
||||
write_impl_tags(
|
||||
3,
|
||||
|
|
|
@ -1967,7 +1967,7 @@ pub fn surgery(
|
|||
let out_gen_start = Instant::now();
|
||||
|
||||
let mut offset = 0;
|
||||
let output = match target.binary_format {
|
||||
match target.binary_format {
|
||||
target_lexicon::BinaryFormat::Elf => {
|
||||
surgery_elf(verbose, &md, &mut exec_mmap, &mut offset, app_obj)
|
||||
}
|
||||
|
@ -2036,8 +2036,6 @@ pub fn surgery(
|
|||
);
|
||||
report_timing("Total", total_duration);
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
49
flake.lock
generated
49
flake.lock
generated
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1649676176,
|
||||
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -17,11 +17,11 @@
|
|||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1656065134,
|
||||
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -31,6 +31,21 @@
|
|||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"locked": {
|
||||
"lastModified": 1656928814,
|
||||
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"locked": {
|
||||
"lastModified": 1629481132,
|
||||
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
|
||||
|
@ -67,11 +82,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1657972522,
|
||||
"narHash": "sha256-JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=",
|
||||
"lastModified": 1661094678,
|
||||
"narHash": "sha256-RtaVb6SqfrgCi20gdju1ogS3u1ocyLnhsgolazrCwL0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "07a2e6a4e31ea48408861607198972d60adaf4ad",
|
||||
"rev": "23534df34c1c499a6c82ce690df06d8c6e4e759d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -92,17 +107,17 @@
|
|||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1656730247,
|
||||
"narHash": "sha256-UTQm1xRDBxbwIJ5bKIj+PNHsi0YPplvWjJLG5KPt0KU=",
|
||||
"lastModified": 1661136859,
|
||||
"narHash": "sha256-o3y1elFGRs/9kqaIeziAnTy9lIWA6VHtQfq0ARRVO2A=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "be0b8a7cbf95d43f23ef0bfa781d644a43c75396",
|
||||
"rev": "6d1418192be90968acfa25e7d7b089e246eb15c4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -113,17 +128,17 @@
|
|||
},
|
||||
"zig": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1651452199,
|
||||
"narHash": "sha256-lq6mTsoPeOCsji/oMFf6953/uOtOhZZ7HSdtjNVDh6I=",
|
||||
"lastModified": 1661042810,
|
||||
"narHash": "sha256-Eq9N4AucjcoucAnTOlGIfPRK1pDpFQ4evPxpTs50LWI=",
|
||||
"owner": "roarkanize",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "c3bd59086dbc731c240c924fd2bc3581720d0035",
|
||||
"rev": "b903ddeb5de948edad18ecc9cf7b01ceb4699622",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[toolchain]
|
||||
channel = "1.61.0" # make sure to update the rust version in Earthfile as well
|
||||
channel = "1.62.1" # make sure to update the rust version in Earthfile as well
|
||||
profile = "default"
|
||||
components = [
|
||||
# for usages of rust-analyzer or similar tools inside `nix develop`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue