Merge pull request #5012 from lucacervello/add-spaces-around-optional-record-field

Add spaces around ? in optional record field
This commit is contained in:
Folkert de Vries 2023-02-15 15:05:08 +01:00 committed by GitHub
commit d1a22316fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

View File

@ -509,6 +509,7 @@ fn format_assigned_field_help<'a, 'buf, T>(
buf.spaces(separator_spaces);
buf.push('?');
buf.spaces(1);
ann.value.format(buf, indent);
}
LabelOnly(name) => {

View File

@ -2164,6 +2164,43 @@ mod test_fmt {
);
}
#[test]
fn type_definition_add_space_around_optional_record() {
expr_formats_to(
indoc!(
r#"
f : { a ?Str }
f"#
),
indoc!(
r#"
f : { a ? Str }
f"#
),
);
expr_formats_to(
indoc!(
r#"
f : {
a ?Str,
}
f"#
),
indoc!(
r#"
f : {
a ? Str,
}
f"#
),
);
}
#[test]
#[ignore]
fn final_comment_in_empty_record_type_definition() {