Skip to content

Commit cecd5fd

Browse files
migeed-zfacebook-github-bot
authored andcommitted
Modify yields to carry yield expressions instead of expressions
Summary: Cleaning up the implementation so that yields can be a list of yield expressions. Clean up some redundant functions as well Reviewed By: ndmitchell Differential Revision: D67684633 fbshipit-source-id: 96f76b22e3cf2ef106466bb8e6d6cc07033d63e6
1 parent ae823e2 commit cecd5fd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

pyre2/bin/binding/bindings.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use ruff_python_ast::ExprLambda;
2525
use ruff_python_ast::ExprName;
2626
use ruff_python_ast::ExprNoneLiteral;
2727
use ruff_python_ast::ExprSubscript;
28+
use ruff_python_ast::ExprYield;
2829
use ruff_python_ast::Identifier;
2930
use ruff_python_ast::Parameters;
3031
use ruff_python_ast::Pattern;
@@ -137,7 +138,7 @@ struct BindingsBuilder<'a> {
137138
/// Accumulate all the return statements
138139
returns: Vec<StmtReturn>,
139140
/// Accumulate all the yield statements
140-
yields: Vec<Expr>,
141+
yields: Vec<ExprYield>,
141142
table: BindingTable,
142143
}
143144

@@ -638,8 +639,8 @@ impl<'a> BindingsBuilder<'a> {
638639
self.bind_lambda(x);
639640
true
640641
}
641-
Expr::Yield(_) => {
642-
self.yields.push(x.clone());
642+
Expr::Yield(y) => {
643+
self.yields.push(y.clone());
643644
false
644645
}
645646
_ => false,
@@ -2070,12 +2071,9 @@ fn return_expr(x: StmtReturn) -> Expr {
20702071
}
20712072
}
20722073

2073-
fn yield_expr(x: Expr) -> Expr {
2074-
match x {
2075-
Expr::Yield(x) => match x.value {
2076-
Some(x) => *x,
2077-
None => Expr::NoneLiteral(ExprNoneLiteral { range: x.range() }),
2078-
},
2079-
_ => Expr::NoneLiteral(ExprNoneLiteral { range: x.range() }),
2074+
fn yield_expr(x: ExprYield) -> Expr {
2075+
match x.value {
2076+
Some(x) => *x,
2077+
None => Expr::NoneLiteral(ExprNoneLiteral { range: x.range }),
20802078
}
20812079
}

0 commit comments

Comments
 (0)