Skip to content

Commit

Permalink
Remove unnessesairy generator bindings
Browse files Browse the repository at this point in the history
Summary:
We will go with an alternative design for generator bindings where we add a flag to ReturnExpr.

I am cleaning up the initial design and following up with the alternative in the next diff.

Reviewed By: stroxler

Differential Revision: D68291196

fbshipit-source-id: c0d0bd7cef9c57b9cc7bd0fba21d837af85d51cf
  • Loading branch information
migeed-z authored and facebook-github-bot committed Jan 16, 2025
1 parent cb0a9fd commit e7f346c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
2 changes: 0 additions & 2 deletions pyre2/pyre2/bin/alt/answers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,8 +1573,6 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
Some(ty) => ty.clone(),
None => self.solve_binding_inner(val),
},
// TODO: zeina decompose the return type here
Binding::GeneratorReturnType(_ann, _val) => Type::any_explicit(),
Binding::AnyType(x) => Type::Any(*x),
Binding::StrType => self.stdlib.str().to_type(),
Binding::TypeParameter(q) => Type::type_form(q.to_type()),
Expand Down
15 changes: 0 additions & 15 deletions pyre2/pyre2/bin/binding/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ pub enum Key {
/// The actual type of the return for a function.
ReturnType(ShortIdentifier),
/// The type of the return for a function after taking generators into account.
#[allow(dead_code)] // TODO: zeina
ExpectedReturnType(ShortIdentifier),
/// I am a use in this module at this location.
Usage(ShortIdentifier),
/// I am an expression that does not have a simple name but needs its type inferred.
Expand Down Expand Up @@ -144,7 +142,6 @@ impl Ranged for Key {
Self::ReturnExpression(_, r) => *r,
Self::YieldTypeOfYield(_, r) => *r,
Self::YieldTypeOfGenerator(x) => x.range(),
Self::ExpectedReturnType(x) => x.range(),
Self::ReturnType(x) => x.range(),
Self::Usage(x) => x.range(),
Self::Anon(r) => *r,
Expand All @@ -169,7 +166,6 @@ impl DisplayWith<ModuleInfo> for Key {
Self::Phi(n, r) => write!(f, "phi {n} {r:?}"),
Self::Narrow(n, r1, r2) => write!(f, "narrow {n} {r1:?} {r2:?}"),
Self::Anywhere(n, r) => write!(f, "anywhere {n} {r:?}"),
Self::ExpectedReturnType(x) => write!(f, "return {} {:?}", ctx.display(x), x.range()),
Self::ReturnType(x) => write!(f, "return {} {:?}", ctx.display(x), x.range()),
Self::ReturnExpression(x, i) => {
write!(f, "return {} {:?} @ {i:?}", ctx.display(x), x.range())
Expand Down Expand Up @@ -358,9 +354,6 @@ pub enum Binding {
/// If the annotation has a type inside it (e.g. `int` then use the annotation).
/// If the annotation doesn't (e.g. it's `Final`), then use the binding.
AnnotatedType(Idx<KeyAnnotation>, Box<Binding>),
/// The type annotation which is to be decomposed to extract the return type.
#[allow(dead_code)] // TODO: zeina
GeneratorReturnType(Option<Idx<KeyAnnotation>>, Box<Binding>),
/// A record of an "augmented assignment" statement like `x -= _`
/// or `a.b *= _`. These desugar to special method calls.
AugAssign(StmtAugAssign),
Expand Down Expand Up @@ -520,14 +513,6 @@ impl DisplayWith<Bindings> for Binding {
Self::AnnotatedType(k1, k2) => {
write!(f, "({}): {}", k2.display_with(ctx), ctx.display(*k1))
}
Self::GeneratorReturnType(k1, k2) => {
write!(
f,
"({}): {}",
k2.display_with(ctx),
ctx.display(k1.unwrap())
)
}
Self::Module(m, path, key) => {
write!(
f,
Expand Down

0 comments on commit e7f346c

Please sign in to comment.