Merge remote-tracking branch 'origin/main' into abilities-syntax

This commit is contained in:
Richard Feldman 2023-08-10 20:29:27 -04:00
commit 2da41be29f
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
524 changed files with 47536 additions and 15089 deletions

View file

@ -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")
};
}
@ -1983,11 +1979,11 @@ mod test_fmt {
expr_formats_to(
indoc!(
r#"
succeed {
succeed {
a: <- get "a" |> map (\x -> x * 2)
|> batch,
|> batch,
b: <- get "b" |> batch,
c: items
c: items
|> List.map \x -> x * 2
}
"#
@ -2036,7 +2032,7 @@ mod test_fmt {
indoc!(
r#"
succeed { a: <- get "a" |> batch,
b: <- get "b" |> batch,
b: <- get "b" |> batch,
}
"#
),
@ -2053,10 +2049,10 @@ mod test_fmt {
expr_formats_to(
indoc!(
r#"
succeed
{
succeed
{
a: <- get "a" |> batch,
b: <- get "b" |> batch,
b: <- get "b" |> batch,
}
"#
),
@ -2076,7 +2072,7 @@ mod test_fmt {
expr_formats_to(
indoc!(
r#"
succeed { a: <- get "a" }
succeed { a: <- get "a" }
{ b: <- get "b" }
"#
),
@ -5447,7 +5443,7 @@ mod test_fmt {
indoc!(
r#"
A := U8
implements [Eq, Hash]
implements [Eq, Hash]
0
"#
@ -5465,7 +5461,7 @@ mod test_fmt {
indoc!(
r#"
A := a where a implements Hash
implements [Eq, Hash]
implements [Eq, Hash]
0
"#
@ -5555,11 +5551,11 @@ mod test_fmt {
r#"
A := U8 implements [Eq { eq, eq1 }]
A := U8 implements [
Eq {
eq,
eq1,
},
]
Eq {
eq,
eq1,
},
]
0
"#
@ -5569,7 +5565,7 @@ mod test_fmt {
expr_formats_same(indoc!(
r#"
A := a where a implements Other
implements [Eq { eq }, Hash { hash }]
has [Eq { eq }, Hash { hash }]
0
"#