mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 09:35:07 +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
|
@ -1133,14 +1133,7 @@ pub struct StmtTry<'a> {
|
|||
handlers: Vec<ComparableExceptHandler<'a>>,
|
||||
orelse: Vec<ComparableStmt<'a>>,
|
||||
finalbody: Vec<ComparableStmt<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct StmtTryStar<'a> {
|
||||
body: Vec<ComparableStmt<'a>>,
|
||||
handlers: Vec<ComparableExceptHandler<'a>>,
|
||||
orelse: Vec<ComparableStmt<'a>>,
|
||||
finalbody: Vec<ComparableStmt<'a>>,
|
||||
is_star: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -1198,7 +1191,6 @@ pub enum ComparableStmt<'a> {
|
|||
Match(StmtMatch<'a>),
|
||||
Raise(StmtRaise<'a>),
|
||||
Try(StmtTry<'a>),
|
||||
TryStar(StmtTryStar<'a>),
|
||||
TypeAlias(StmtTypeAlias<'a>),
|
||||
Assert(StmtAssert<'a>),
|
||||
Import(StmtImport<'a>),
|
||||
|
@ -1358,24 +1350,14 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> {
|
|||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
is_star,
|
||||
range: _,
|
||||
}) => Self::Try(StmtTry {
|
||||
body: body.iter().map(Into::into).collect(),
|
||||
handlers: handlers.iter().map(Into::into).collect(),
|
||||
orelse: orelse.iter().map(Into::into).collect(),
|
||||
finalbody: finalbody.iter().map(Into::into).collect(),
|
||||
}),
|
||||
ast::Stmt::TryStar(ast::StmtTryStar {
|
||||
body,
|
||||
handlers,
|
||||
orelse,
|
||||
finalbody,
|
||||
range: _,
|
||||
}) => Self::TryStar(StmtTryStar {
|
||||
body: body.iter().map(Into::into).collect(),
|
||||
handlers: handlers.iter().map(Into::into).collect(),
|
||||
orelse: orelse.iter().map(Into::into).collect(),
|
||||
finalbody: finalbody.iter().map(Into::into).collect(),
|
||||
is_star: *is_star,
|
||||
}),
|
||||
ast::Stmt::Assert(ast::StmtAssert {
|
||||
test,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue