Skip to content

Commit

Permalink
Improve formatting of record_pat
Browse files Browse the repository at this point in the history
  • Loading branch information
parno committed Nov 16, 2023
1 parent 419a86d commit 113282d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ enum ThisOrThat {
proof fn uses_is(t: ThisOrThat) {
match t {
ThisOrThat::This(..) => assert(t is This),
ThisOrThat::That{..} => assert(t is That),
ThisOrThat::That { .. } => assert(t is That),
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/wip.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
verus! {

fn test() {
for CKeyKV in v {
for CKeyKV { k, v } in v {
res.insert(k, v);
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,13 @@ fn to_doc<'a>(
//Rule::wildcard_pat => arena.text("_"),
Rule::end_only_range_pat => map_to_doc(ctx, arena, pair),
Rule::ref_pat => arena.text("&").append(map_to_doc(ctx, arena, pair)),
Rule::record_pat => map_to_doc(ctx, arena, pair),
Rule::record_pat_field_list => comma_delimited(ctx, arena, pair).braces().group(),
Rule::record_pat => arena.concat(pair.into_inner().map(|p| match p.as_rule() {
Rule::path => to_doc(ctx, p, arena).append(arena.text(" ")),
_ => to_doc(ctx, p, arena),
})),
Rule::record_pat_field_list => {
spaced_braces(arena, comma_delimited(ctx, arena, pair)).group()
}
Rule::record_pat_field => map_to_doc(ctx, arena, pair),
Rule::tuple_struct_pat_inner => comma_delimited(ctx, arena, pair).parens().group(),
Rule::tuple_struct_pat => map_to_doc(ctx, arena, pair),
Expand Down
15 changes: 15 additions & 0 deletions tests/rustfmt-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ fn len<T>(l: List<T>) -> nat {
List::Cons(_, tl) => 1 + len(*tl),
}
}
fn uses_is(t: ThisOrThat) {
match t {
ThisOrThat::This(..) => assert(t),
ThisOrThat::That{..} => assert(t),
}
}
"#;
compare(file);
}
Expand Down Expand Up @@ -378,6 +386,13 @@ fn test() {
res.insert(k, v);
}
}
fn test() {
for CKeyKV { k, v } in v {
res.insert(k, v);
}
}
"#;
compare(file);
}

0 comments on commit 113282d

Please sign in to comment.