resolve: extract resolve_params
.
This commit is contained in:
parent
a24f636e60
commit
af06bfb84c
1 changed files with 15 additions and 20 deletions
|
@ -425,14 +425,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
|
||||||
self.label_ribs.push(Rib::new(rib_kind));
|
self.label_ribs.push(Rib::new(rib_kind));
|
||||||
|
|
||||||
// Add each argument to the rib.
|
// Add each argument to the rib.
|
||||||
let mut bindings_list = FxHashMap::default();
|
self.resolve_params(&declaration.inputs);
|
||||||
for argument in &declaration.inputs {
|
|
||||||
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
|
|
||||||
|
|
||||||
self.visit_ty(&argument.ty);
|
|
||||||
|
|
||||||
debug!("(resolving function) recorded argument");
|
|
||||||
}
|
|
||||||
visit::walk_fn_ret_ty(self, &declaration.output);
|
visit::walk_fn_ret_ty(self, &declaration.output);
|
||||||
|
|
||||||
// Resolve the function body, potentially inside the body of an async closure
|
// Resolve the function body, potentially inside the body of an async closure
|
||||||
|
@ -1135,6 +1129,15 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
fn resolve_local(&mut self, local: &Local) {
|
||||||
// Resolve the type.
|
// Resolve the type.
|
||||||
walk_list!(self, visit_ty, &local.ty);
|
walk_list!(self, visit_ty, &local.ty);
|
||||||
|
@ -1860,20 +1863,12 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||||
// `async |x| ...` gets desugared to `|x| future_from_generator(|| ...)`, so we need to
|
// `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
|
// 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.
|
// closure are detected as upvars rather than normal closure arg usages.
|
||||||
ExprKind::Closure(
|
ExprKind::Closure(_, IsAsync::Async { .. }, _, ref fn_decl, ref body, _span) => {
|
||||||
_, IsAsync::Async { .. }, _,
|
self.ribs[ValueNS].push(Rib::new(NormalRibKind));
|
||||||
ref fn_decl, ref body, _span,
|
|
||||||
) => {
|
|
||||||
let rib_kind = NormalRibKind;
|
|
||||||
self.ribs[ValueNS].push(Rib::new(rib_kind));
|
|
||||||
// Resolve arguments:
|
// Resolve arguments:
|
||||||
let mut bindings_list = FxHashMap::default();
|
self.resolve_params(&fn_decl.inputs);
|
||||||
for argument in &fn_decl.inputs {
|
// No need to resolve return type --
|
||||||
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
|
// the outer closure return type is `FunctionRetTy::Default`.
|
||||||
self.visit_ty(&argument.ty);
|
|
||||||
}
|
|
||||||
// No need to resolve return type-- the outer closure return type is
|
|
||||||
// FunctionRetTy::Default
|
|
||||||
|
|
||||||
// Now resolve the inner closure
|
// Now resolve the inner closure
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue