Merge pull request #4429 from austinclem1/main

add missing indent when formatting single-quoted char in pattern
This commit is contained in:
Richard Feldman 2022-10-31 17:56:06 -07:00 committed by GitHub
commit 50d9755758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -152,6 +152,7 @@ impl<'a> Formattable for Pattern<'a> {
}
StrLiteral(literal) => fmt_str_literal(buf, *literal, indent),
SingleQuote(string) => {
buf.indent(indent);
buf.push('\'');
buf.push_str(string);
buf.push('\'');

View file

@ -3864,6 +3864,17 @@ mod test_fmt {
);
}
#[test]
fn when_with_single_quote_char() {
expr_formats_same(indoc!(
r#"
when x is
'0' -> 0
'1' -> 1
"#
));
}
// NEWLINES
#[test]