self.label_ribs.push(Rib::new(rib_kind));
// Add each argument to the rib.
- let mut bindings_list = FxHashMap::default();
- for argument in &declaration.inputs {
- self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
-
- self.visit_ty(&argument.ty);
+ self.resolve_params(&declaration.inputs);
- debug!("(resolving function) recorded argument");
- }
visit::walk_fn_ret_ty(self, &declaration.output);
// Resolve the function body, potentially inside the body of an async closure
}
}
+ fn resolve_params(&mut self, params: &[Arg]) {
+ let mut bindings_list = FxHashMap::default();
+ for param in params {
+ self.resolve_pattern(¶m.pat, PatternSource::FnParam, &mut bindings_list);
+ self.visit_ty(¶m.ty);
+ debug!("(resolving function / closure) recorded parameter");
+ }
+ }
+
fn resolve_local(&mut self, local: &Local) {
// Resolve the type.
walk_list!(self, visit_ty, &local.ty);
// `async |x| ...` gets desugared to `|x| future_from_generator(|| ...)`, so we need to
// resolve the arguments within the proper scopes so that usages of them inside the
// closure are detected as upvars rather than normal closure arg usages.
- ExprKind::Closure(
- _, IsAsync::Async { .. }, _,
- ref fn_decl, ref body, _span,
- ) => {
- let rib_kind = NormalRibKind;
- self.ribs[ValueNS].push(Rib::new(rib_kind));
+ ExprKind::Closure(_, IsAsync::Async { .. }, _, ref fn_decl, ref body, _span) => {
+ self.ribs[ValueNS].push(Rib::new(NormalRibKind));
// Resolve arguments:
- let mut bindings_list = FxHashMap::default();
- for argument in &fn_decl.inputs {
- self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
- self.visit_ty(&argument.ty);
- }
- // No need to resolve return type-- the outer closure return type is
- // FunctionRetTy::Default
+ self.resolve_params(&fn_decl.inputs);
+ // No need to resolve return type --
+ // the outer closure return type is `FunctionRetTy::Default`.
// Now resolve the inner closure
{