Merge pull request #4116 from charliermarsh/charlie/f-string

Avoid creating unused JoinedStr in FStringParser
This commit is contained in:
Jeong YunWon 2022-08-23 19:30:36 +09:00 committed by GitHub
commit b21ed24025
14 changed files with 623 additions and 787 deletions

View file

@ -34,19 +34,10 @@ pub fn parse_strings(values: Vec<(Location, (String, StringKind))>) -> Result<Ex
StringKind::Normal | StringKind::U => current.push(string),
StringKind::F => {
has_fstring = true;
let values = if let ExprKind::JoinedStr { values } =
parse_located_fstring(&string, location)
.map_err(|e| LexicalError {
location,
error: LexicalErrorType::FStringError(e.error),
})?
.node
{
values
} else {
unreachable!("parse_located_fstring returned a non-JoinedStr.")
};
for value in values {
for value in parse_located_fstring(&string, location).map_err(|e| LexicalError {
location,
error: LexicalErrorType::FStringError(e.error),
})? {
match value.node {
ExprKind::FormattedValue { .. } => {
if !current.is_empty() {