mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-26 06:24:29 +00:00
Avoid creating unused JoinedStr in FStringParser
This commit is contained in:
parent
53c48bf6b9
commit
2345bc895d
14 changed files with 598 additions and 775 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue