From e7f346c996f17f168aaec8756331941ba757bb0a Mon Sep 17 00:00:00 2001 From: Zeina Migeed Date: Thu, 16 Jan 2025 15:24:33 -0800 Subject: [PATCH] Remove unnessesairy generator bindings 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 --- pyre2/pyre2/bin/alt/answers.rs | 2 -- pyre2/pyre2/bin/binding/binding.rs | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/pyre2/pyre2/bin/alt/answers.rs b/pyre2/pyre2/bin/alt/answers.rs index e147d00859..14f137c4fc 100644 --- a/pyre2/pyre2/bin/alt/answers.rs +++ b/pyre2/pyre2/bin/alt/answers.rs @@ -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()), diff --git a/pyre2/pyre2/bin/binding/binding.rs b/pyre2/pyre2/bin/binding/binding.rs index e9806b6664..e1317262b2 100644 --- a/pyre2/pyre2/bin/binding/binding.rs +++ b/pyre2/pyre2/bin/binding/binding.rs @@ -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. @@ -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, @@ -169,7 +166,6 @@ impl DisplayWith 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()) @@ -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, Box), - /// The type annotation which is to be decomposed to extract the return type. - #[allow(dead_code)] // TODO: zeina - GeneratorReturnType(Option>, Box), /// A record of an "augmented assignment" statement like `x -= _` /// or `a.b *= _`. These desugar to special method calls. AugAssign(StmtAugAssign), @@ -520,14 +513,6 @@ impl DisplayWith 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,