From af891b9bd2fe72cd64c32ee3635b7554dcbc141f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 11 Aug 2019 01:57:20 +0900 Subject: [PATCH] Remove support of if-let expressions from #[project] attribute --- pin-project-internal/src/project.rs | 11 ---------- src/lib.rs | 33 ++--------------------------- tests/project.rs | 13 ------------ 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/pin-project-internal/src/project.rs b/pin-project-internal/src/project.rs index 57cf16d7..744134aa 100644 --- a/pin-project-internal/src/project.rs +++ b/pin-project-internal/src/project.rs @@ -46,7 +46,6 @@ impl Replace for Local { impl Replace for Expr { fn replace(&mut self, register: &mut Register) { match self { - Expr::If(expr) => expr.replace(register), Expr::ForLoop(ExprForLoop { pat, .. }) => pat.replace(register), Expr::Let(ExprLet { pats, .. }) => pats.replace(register), @@ -73,16 +72,6 @@ impl Replace for Expr { } } -impl Replace for ExprIf { - fn replace(&mut self, register: &mut Register) { - self.cond.replace(register); - - if let Some(Expr::If(expr)) = self.else_branch.as_mut().map(|(_, expr)| &mut **expr) { - expr.replace(register); - } - } -} - impl Replace for Punctuated { fn replace(&mut self, register: &mut Register) { self.iter_mut().for_each(|pat| pat.replace(register)); diff --git a/src/lib.rs b/src/lib.rs index 29f14905..f00454c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -157,6 +157,8 @@ /// /// ## Examples /// +/// The following two syntaxes are supported. +/// /// ### `let` bindings /// /// ```rust @@ -212,37 +214,6 @@ /// } /// } /// ``` -/// -/// ### `if let` expressions -/// -/// When used against `if let` expressions, the `#[project]` attribute records -/// the name of the structure destructed with the first `if let`. Destructing -/// different structures in the after second times will not generate wrong code. -/// -/// ```rust -/// use pin_project::{project, pin_projectable}; -/// # use std::pin::Pin; -/// -/// #[pin_projectable] -/// enum Foo { -/// Tuple(#[pin] A, B), -/// Struct { field: C }, -/// Unit, -/// } -/// -/// impl Foo { -/// #[project] // Nightly does not need a dummy attribute to the function. -/// fn baz(self: Pin<&mut Self>) { -/// #[project] -/// { -/// if let Foo::Tuple(x, y) = self.project() { -/// let _: Pin<&mut A> = x; -/// let _: &mut B = y; -/// } -/// } -/// } -/// } -/// ``` #[cfg(feature = "project_attr")] #[doc(inline)] pub use pin_project_internal::project; diff --git a/tests/project.rs b/tests/project.rs index adc0caca..c83741ea 100644 --- a/tests/project.rs +++ b/tests/project.rs @@ -79,17 +79,4 @@ fn test_project_attr() { } Baz::None => {} } - - #[project] - { - if let Baz::Variant1(x, y) = baz { - let x: Pin<&mut i32> = x; - assert_eq!(*x, 1); - - let y: &mut i32 = y; - assert_eq!(*y, 2); - } else if let Option::Some(_) = Some(1) { - // Check that don't replace different types by mistake - } - } }