Lower closure binders to hir & properly check them
This commit is contained in:
parent
f89ef3cf66
commit
c2dbd62c7c
16 changed files with 214 additions and 103 deletions
|
@ -1931,6 +1931,7 @@ pub enum ExprKind<'hir> {
|
|||
/// This may also be a generator literal or an `async block` as indicated by the
|
||||
/// `Option<Movability>`.
|
||||
Closure {
|
||||
binder: &'hir ClosureBinder,
|
||||
capture_clause: CaptureBy,
|
||||
bound_generic_params: &'hir [GenericParam<'hir>],
|
||||
fn_decl: &'hir FnDecl<'hir>,
|
||||
|
@ -2715,6 +2716,17 @@ impl FnRetTy<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Represents `for<...>` binder before a closure
|
||||
#[derive(Copy, Clone, Debug, HashStable_Generic)]
|
||||
pub enum ClosureBinder {
|
||||
/// Binder is not specified.
|
||||
Default,
|
||||
/// Binder is specified.
|
||||
///
|
||||
/// Span points to the whole `for<...>`.
|
||||
For { span: Span },
|
||||
}
|
||||
|
||||
#[derive(Encodable, Debug, HashStable_Generic)]
|
||||
pub struct Mod<'hir> {
|
||||
pub spans: ModSpans,
|
||||
|
|
|
@ -925,7 +925,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(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1145,6 +1145,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
walk_list!(visitor, visit_arm, arms);
|
||||
}
|
||||
ExprKind::Closure {
|
||||
binder: _,
|
||||
bound_generic_params,
|
||||
ref fn_decl,
|
||||
body,
|
||||
|
@ -1153,7 +1154,13 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
movability: _,
|
||||
} => {
|
||||
walk_list!(visitor, visit_generic_param, bound_generic_params);
|
||||
visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, expression.hir_id)
|
||||
visitor.visit_fn(
|
||||
FnKind::Closure,
|
||||
fn_decl,
|
||||
body,
|
||||
expression.span,
|
||||
expression.hir_id,
|
||||
)
|
||||
}
|
||||
ExprKind::Block(ref block, ref opt_label) => {
|
||||
walk_list!(visitor, visit_label, opt_label);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue