Skip to content

Commit af06bfb

Browse files
committed
resolve: extract resolve_params.
1 parent a24f636 commit af06bfb

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/librustc_resolve/late.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
425425
self.label_ribs.push(Rib::new(rib_kind));
426426

427427
// Add each argument to the rib.
428-
let mut bindings_list = FxHashMap::default();
429-
for argument in &declaration.inputs {
430-
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
431-
432-
self.visit_ty(&argument.ty);
428+
self.resolve_params(&declaration.inputs);
433429

434-
debug!("(resolving function) recorded argument");
435-
}
436430
visit::walk_fn_ret_ty(self, &declaration.output);
437431

438432
// Resolve the function body, potentially inside the body of an async closure
@@ -1135,6 +1129,15 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
11351129
}
11361130
}
11371131

1132+
fn resolve_params(&mut self, params: &[Arg]) {
1133+
let mut bindings_list = FxHashMap::default();
1134+
for param in params {
1135+
self.resolve_pattern(&param.pat, PatternSource::FnParam, &mut bindings_list);
1136+
self.visit_ty(&param.ty);
1137+
debug!("(resolving function / closure) recorded parameter");
1138+
}
1139+
}
1140+
11381141
fn resolve_local(&mut self, local: &Local) {
11391142
// Resolve the type.
11401143
walk_list!(self, visit_ty, &local.ty);
@@ -1860,20 +1863,12 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
18601863
// `async |x| ...` gets desugared to `|x| future_from_generator(|| ...)`, so we need to
18611864
// resolve the arguments within the proper scopes so that usages of them inside the
18621865
// closure are detected as upvars rather than normal closure arg usages.
1863-
ExprKind::Closure(
1864-
_, IsAsync::Async { .. }, _,
1865-
ref fn_decl, ref body, _span,
1866-
) => {
1867-
let rib_kind = NormalRibKind;
1868-
self.ribs[ValueNS].push(Rib::new(rib_kind));
1866+
ExprKind::Closure(_, IsAsync::Async { .. }, _, ref fn_decl, ref body, _span) => {
1867+
self.ribs[ValueNS].push(Rib::new(NormalRibKind));
18691868
// Resolve arguments:
1870-
let mut bindings_list = FxHashMap::default();
1871-
for argument in &fn_decl.inputs {
1872-
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
1873-
self.visit_ty(&argument.ty);
1874-
}
1875-
// No need to resolve return type-- the outer closure return type is
1876-
// FunctionRetTy::Default
1869+
self.resolve_params(&fn_decl.inputs);
1870+
// No need to resolve return type --
1871+
// the outer closure return type is `FunctionRetTy::Default`.
18771872

18781873
// Now resolve the inner closure
18791874
{

0 commit comments

Comments
 (0)