- ItemKind::Fn(ref declaration,
- FnHeader { asyncness: IsAsync::Async(async_closure_id), .. },
- ref generics,
- ref body) => {
- // Async functions are desugared from `async fn foo() { .. }`
- // to `fn foo() { future_from_generator(move || ... ) }`,
- // so we have to visit the body inside the closure scope
- self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
- this.visit_vis(&item.vis);
- this.visit_ident(item.ident);
- this.visit_generics(generics);
- let rib_kind = ItemRibKind;
- this.ribs[ValueNS].push(Rib::new(rib_kind));
- this.label_ribs.push(Rib::new(rib_kind));
- let mut bindings_list = FxHashMap();
- for argument in &declaration.inputs {
- this.resolve_pattern(
- &argument.pat, PatternSource::FnParam, &mut bindings_list);
- this.visit_ty(&*argument.ty);
- }
- visit::walk_fn_ret_ty(this, &declaration.output);
-
- // Now resolve the inner closure
- {
- let rib_kind = ClosureRibKind(async_closure_id);
- this.ribs[ValueNS].push(Rib::new(rib_kind));
- this.label_ribs.push(Rib::new(rib_kind));
- // No need to resolve either arguments nor return type,
- // as this closure has neither
-
- // Resolve the body
- this.visit_block(body);
- this.label_ribs.pop();
- this.ribs[ValueNS].pop();
- }
- this.label_ribs.pop();
- this.ribs[ValueNS].pop();
-
- walk_list!(this, visit_attribute, &item.attrs);
- })
- }