mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-18 18:45:23 +00:00
Fix the end location of an implicitly-concatenated string
This commit is contained in:
parent
009f2c4d38
commit
dd01ab1c9e
6 changed files with 7 additions and 6 deletions
|
@ -24,7 +24,7 @@ expression: parse_ast
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 1,
|
row: 1,
|
||||||
column: 8,
|
column: 17,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
|
@ -24,7 +24,7 @@ expression: parse_ast
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 1,
|
row: 1,
|
||||||
column: 8,
|
column: 17,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
|
@ -24,7 +24,7 @@ expression: parse_ast
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 1,
|
row: 1,
|
||||||
column: 8,
|
column: 22,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
|
@ -24,7 +24,7 @@ expression: parse_ast
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 1,
|
row: 1,
|
||||||
column: 9,
|
column: 18,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
|
@ -24,7 +24,7 @@ expression: parse_ast
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 1,
|
row: 1,
|
||||||
column: 9,
|
column: 22,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub fn parse_strings(
|
||||||
// Preserve the initial location and kind.
|
// Preserve the initial location and kind.
|
||||||
let initial_start = values[0].0;
|
let initial_start = values[0].0;
|
||||||
let initial_end = values[0].2;
|
let initial_end = values[0].2;
|
||||||
|
let last_end = values.last().unwrap().2;
|
||||||
let initial_kind = (values[0].1 .1 == StringKind::U).then(|| "u".to_owned());
|
let initial_kind = (values[0].1 .1 == StringKind::U).then(|| "u".to_owned());
|
||||||
|
|
||||||
// Optimization: fast-track the common case of a single string.
|
// Optimization: fast-track the common case of a single string.
|
||||||
|
@ -84,7 +85,7 @@ pub fn parse_strings(
|
||||||
Ok(if has_fstring {
|
Ok(if has_fstring {
|
||||||
Expr::new(
|
Expr::new(
|
||||||
initial_start,
|
initial_start,
|
||||||
initial_end,
|
last_end,
|
||||||
ExprKind::JoinedStr { values: deduped },
|
ExprKind::JoinedStr { values: deduped },
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue