Skip to content

Commit

Permalink
Rename within_fn_param to outermost_fn_param_pat
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Oct 27, 2020
1 parent ca41681 commit bdd1b85
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_typeck/src/check/gather_locals.rs
Expand Up @@ -14,16 +14,16 @@ pub(super) struct GatherLocalsVisitor<'a, 'tcx> {
// params are special cases of pats, but we want to handle them as
// *distinct* cases. so track when we are hitting a pat *within* an fn
// param.
within_fn_param: bool,
outermost_fn_param_pat: bool,
}

impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
pub(super) fn new(
fcx: &'a FnCtxt<'a, 'tcx>,
parent_id: hir::HirId,
within_fn_param: bool,
outermost_fn_param_pat: bool,
) -> Self {
Self { fcx, parent_id, within_fn_param }
Self { fcx, parent_id, outermost_fn_param_pat }
}

fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
Expand Down Expand Up @@ -98,17 +98,17 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
}

fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
let old_within_fn_param = mem::replace(&mut self.within_fn_param, true);
let old_outermost_fn_param_pat = mem::replace(&mut self.outermost_fn_param_pat, true);
intravisit::walk_param(self, param);
self.within_fn_param = old_within_fn_param;
self.outermost_fn_param_pat = old_outermost_fn_param_pat;
}

// Add pattern bindings.
fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
if let PatKind::Binding(_, _, ident, _) = p.kind {
let var_ty = self.assign(p.span, p.hir_id, None);

if self.within_fn_param {
if self.outermost_fn_param_pat {
if !self.fcx.tcx.features().unsized_fn_params {
self.fcx.require_type_is_sized(
var_ty,
Expand All @@ -129,9 +129,9 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
var_ty
);
}
let old_within_fn_param = mem::replace(&mut self.within_fn_param, false);
let old_outermost_fn_param_pat = mem::replace(&mut self.outermost_fn_param_pat, false);
intravisit::walk_pat(self, p);
self.within_fn_param = old_within_fn_param;
self.outermost_fn_param_pat = old_outermost_fn_param_pat;
}

// Don't descend into the bodies of nested closures.
Expand Down

0 comments on commit bdd1b85

Please sign in to comment.