mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-19 02:55:20 +00:00
Remove Stmt::TryStar
(#6566)
## Summary Instead, we set an `is_star` flag on `Stmt::Try`. This is similar to the pattern we've migrated towards for `Stmt::For` (removing `Stmt::AsyncFor`) and friends. While these are significant differences for an interpreter, we tend to handle these cases identically or nearly identically. ## Test Plan `cargo test`
This commit is contained in:
parent
09c8b17661
commit
96d310fbab
33 changed files with 70 additions and 489 deletions
|
@ -952,6 +952,7 @@ TryStatement: ast::Stmt = {
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: false,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
@ -965,12 +966,13 @@ TryStatement: ast::Stmt = {
|
|||
.map(Ranged::end)
|
||||
.or_else(|| handlers.last().map(Ranged::end))
|
||||
.unwrap();
|
||||
ast::Stmt::TryStar(
|
||||
ast::StmtTryStar {
|
||||
ast::Stmt::Try(
|
||||
ast::StmtTry {
|
||||
body,
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: true,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
@ -985,6 +987,7 @@ TryStatement: ast::Stmt = {
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: false,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// auto-generated: "lalrpop 0.20.0"
|
||||
// sha3: eea7f30d1f9d5648f73bb9aeb9c0d61be448c1d648b743eb3155da459e4e6038
|
||||
// sha3: d7e633596695f78340d0d083cd0561185ac7f8efadb0297003c81a41031f6e24
|
||||
use num_bigint::BigInt;
|
||||
use ruff_text_size::TextSize;
|
||||
use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind};
|
||||
|
@ -35125,6 +35125,7 @@ fn __action150<
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: false,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
@ -35155,12 +35156,13 @@ fn __action151<
|
|||
.map(Ranged::end)
|
||||
.or_else(|| handlers.last().map(Ranged::end))
|
||||
.unwrap();
|
||||
ast::Stmt::TryStar(
|
||||
ast::StmtTryStar {
|
||||
ast::Stmt::Try(
|
||||
ast::StmtTry {
|
||||
body,
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: true,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
@ -35189,6 +35191,7 @@ fn __action152<
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star: false,
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
|
|
@ -243,6 +243,7 @@ expression: parse_ast
|
|||
],
|
||||
orelse: [],
|
||||
finalbody: [],
|
||||
is_star: false,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
|
@ -3,8 +3,8 @@ source: crates/ruff_python_parser/src/parser.rs
|
|||
expression: parse_ast
|
||||
---
|
||||
[
|
||||
TryStar(
|
||||
StmtTryStar {
|
||||
Try(
|
||||
StmtTry {
|
||||
range: 0..260,
|
||||
body: [
|
||||
Raise(
|
||||
|
@ -436,6 +436,7 @@ expression: parse_ast
|
|||
],
|
||||
orelse: [],
|
||||
finalbody: [],
|
||||
is_star: true,
|
||||
},
|
||||
),
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue