Skip to content

Commit 125b578

Browse files
authored
Remove WithItem<"as"> goal (#6868)
1 parent 350f8db commit 125b578

File tree

2 files changed

+5041
-5182
lines changed

2 files changed

+5041
-5182
lines changed

crates/ruff_python_parser/src/python.lalrpop

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ WithStatement: ast::Stmt = {
10541054

10551055
WithItems: Vec<ast::WithItem> = {
10561056
"(" <WithItemsNoAs> ","? ")",
1057-
"(" <left:(<WithItemsNoAs> ",")?> <mid:WithItem<"as">> <right:("," <WithItem<"all">>)*> ","? ")" => {
1057+
"(" <left:(<WithItemsNoAs> ",")?> <mid:WithItemAs> <right:("," <WithItem<"all">>)*> ","? ")" => {
10581058
left.into_iter().flatten().chain([mid]).chain(right).collect()
10591059
},
10601060
<WithItem<"no-withitems">> => vec![<>],
@@ -1071,12 +1071,16 @@ WithItemsNoAs: Vec<ast::WithItem> = {
10711071
}
10721072

10731073
WithItem<Goal>: ast::WithItem = {
1074-
<location:@L> <context_expr: Test<Goal>> <end_location:@R> if Goal != "as" => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1074+
<location:@L> <context_expr: Test<Goal>> <end_location:@R> => ast::WithItem { context_expr, optional_vars: None, range: (location..end_location).into() },
1075+
<WithItemAs>,
1076+
};
1077+
1078+
WithItemAs: ast::WithItem = {
10751079
<location:@L> <context_expr:Test<"all">> "as" <vars:Expression<"all">> <end_location:@R> => {
10761080
let optional_vars = Some(Box::new(set_context(vars, ast::ExprContext::Store)));
10771081
ast::WithItem { context_expr, optional_vars, range: (location..end_location).into() }
10781082
},
1079-
};
1083+
}
10801084

10811085
FuncDef: ast::Stmt = {
10821086
<location:@L> <decorator_list:Decorator*> <is_async:"async"?> "def" <name:Identifier> <type_params:TypeParams?> <args:Parameters> <r:("->" <Test<"all">>)?> ":" <body:Suite> => {

0 commit comments

Comments
 (0)