Skip to content

Commit e51a387

Browse files
bors[bot]taiki-e
andauthored
Merge #207
207: Do not skip visiting nested expressions r=taiki-e a=taiki-e Fixes #206 and hyperium/hyper#2199 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents e974e5b + 05a7373 commit e51a387

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

pin-project-internal/src/project.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ fn replace_item_fn(item: &mut ItemFn, mutability: Mutability) -> Result<()> {
208208

209209
fn visit_stmt(&mut self, node: &mut Stmt) -> Result<()> {
210210
match node {
211-
Stmt::Expr(expr) | Stmt::Semi(expr, _) => {
212-
visit_mut::visit_expr_mut(self, expr);
213-
self.visit_expr(expr)
214-
}
211+
Stmt::Expr(expr) | Stmt::Semi(expr, _) => self.visit_expr(expr),
215212
Stmt::Local(local) => {
216213
visit_mut::visit_local_mut(self, local);
217214
if let Some(attr) = local.attrs.find_remove(self.name())? {
@@ -226,6 +223,7 @@ fn replace_item_fn(item: &mut ItemFn, mutability: Mutability) -> Result<()> {
226223
}
227224

228225
fn visit_expr(&mut self, node: &mut Expr) -> Result<()> {
226+
visit_mut::visit_expr_mut(self, node);
229227
let attr = match node {
230228
Expr::Match(expr) => expr.attrs.find_remove(self.name())?,
231229
Expr::If(expr_if) => {

tests/project.rs

+30
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,33 @@ fn non_stmt_expr_match() {
204204
},
205205
);
206206
}
207+
208+
// https://github.com/taiki-e/pin-project/issues/206
209+
#[test]
210+
#[project]
211+
fn issue_206() {
212+
#[pin_project]
213+
enum Enum<A> {
214+
Variant(#[pin] A),
215+
}
216+
217+
let mut x = Enum::Variant(1);
218+
let x = Pin::new(&mut x).project();
219+
220+
Some({
221+
#[project]
222+
match &x {
223+
Enum::Variant(_) => {}
224+
}
225+
});
226+
227+
loop {
228+
let _ = {
229+
#[project]
230+
match &x {
231+
Enum::Variant(_) => {}
232+
}
233+
};
234+
break;
235+
}
236+
}

0 commit comments

Comments
 (0)