Parse deprecated interpolation syntax differently

This commit is contained in:
Richard Feldman 2024-01-06 17:41:03 -05:00
parent 08ab7996a0
commit af8e9c7292
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
7 changed files with 47 additions and 11 deletions

View file

@ -612,9 +612,20 @@ fn format_str_segment(seg: &StrSegment, buf: &mut Buf, indent: u16) {
buf.push('\\');
buf.push(escaped.to_parsed_char());
}
Interpolated(loc_expr) => {
DeprecatedInterpolated(loc_expr) => {
buf.push_str("\\(");
// e.g. (name) in "Hi, \(name)!"
// e.g. (name) in "Hi, $(name)!"
loc_expr.value.format_with_options(
buf,
Parens::NotNeeded, // We already printed parens!
Newlines::No, // Interpolations can never have newlines
indent,
);
buf.push(')');
}
Interpolated(loc_expr) => {
buf.push_str("$(");
// e.g. (name) in "Hi, $(name)!"
loc_expr.value.format_with_options(
buf,
Parens::NotNeeded, // We already printed parens!

View file

@ -656,6 +656,9 @@ impl<'a> RemoveSpaces<'a> for StrSegment<'a> {
StrSegment::Unicode(t) => StrSegment::Unicode(t.remove_spaces(arena)),
StrSegment::EscapedChar(c) => StrSegment::EscapedChar(c),
StrSegment::Interpolated(t) => StrSegment::Interpolated(t.remove_spaces(arena)),
StrSegment::DeprecatedInterpolated(t) => {
StrSegment::DeprecatedInterpolated(t.remove_spaces(arena))
}
}
}
}