1
Fork 0

Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot

Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
This commit is contained in:
Dylan DPC 2022-07-14 14:14:21 +05:30 committed by GitHub
commit e5a86d7358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
91 changed files with 843 additions and 208 deletions

View file

@ -928,7 +928,7 @@ pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<'
FnKind::ItemFn(_, generics, ..) => {
visitor.visit_generics(generics);
}
FnKind::Method(..) | FnKind::Closure => {}
FnKind::Closure | FnKind::Method(..) => {}
}
}
@ -1147,14 +1147,15 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
visitor.visit_expr(subexpression);
walk_list!(visitor, visit_arm, arms);
}
ExprKind::Closure {
ExprKind::Closure(&Closure {
binder: _,
bound_generic_params,
ref fn_decl,
fn_decl,
body,
capture_clause: _,
fn_decl_span: _,
movability: _,
} => {
}) => {
walk_list!(visitor, visit_generic_param, bound_generic_params);
visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, expression.hir_id)
}