Merge pull request #4903 from joshuawarner32/fix-nested_backpassing_no_newline_before

Fix formatting of backpassing in a nested def with no newline
This commit is contained in:
Ayaz 2023-01-19 22:55:03 -06:00 committed by GitHub
commit 78fc30484e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 1 deletions

View File

@ -420,7 +420,7 @@ pub fn fmt_body<'a, 'buf>(
);
}
}
Expr::Defs(..) | Expr::BinOps(_, _) => {
Expr::Defs(..) | Expr::BinOps(_, _) | Expr::Backpassing(..) => {
// Binop chains always get a newline. Otherwise you can have things like:
//
// something = foo

View File

@ -0,0 +1,7 @@
main =
task =
file <-
foo
bar
task
42

View File

@ -0,0 +1,97 @@
Defs(
Defs {
tags: [
Index(2147483648),
],
regions: [
@0-71,
],
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 0),
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@0-4 Identifier(
"main",
),
@11-71 SpaceBefore(
Defs(
Defs {
tags: [
Index(2147483648),
],
regions: [
@11-62,
],
space_before: [
Slice(start = 0, length = 0),
],
space_after: [
Slice(start = 0, length = 0),
],
spaces: [],
type_defs: [],
value_defs: [
Body(
@11-15 Identifier(
"task",
),
@18-62 Backpassing(
[
@18-22 Identifier(
"file",
),
],
@43-46 SpaceBefore(
Var {
module_name: "",
ident: "foo",
},
[
Newline,
],
),
@59-62 SpaceBefore(
Var {
module_name: "",
ident: "bar",
},
[
Newline,
],
),
),
),
],
},
@67-71 SpaceBefore(
Var {
module_name: "",
ident: "task",
},
[
Newline,
],
),
),
[
Newline,
],
),
),
],
},
@72-74 SpaceBefore(
Num(
"42",
),
[
Newline,
],
),
)

View File

@ -0,0 +1,6 @@
main =
task = file <-
foo
bar
task
42

View File

@ -325,6 +325,7 @@ mod test_snapshots {
pass/negative_in_apply_def.expr,
pass/negative_int.expr,
pass/nested_def_annotation.moduledefs,
pass/nested_backpassing_no_newline_before.expr,
pass/nested_def_without_newline.expr,
pass/nested_if.expr,
pass/nested_module.header,