Rename within_fn_param to outermost_fn_param_pat
This commit is contained in:
parent
ca41681bf0
commit
bdd1b85f95
@ -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> {
|
||||
@ -98,9 +98,9 @@ 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.
|
||||
@ -108,7 +108,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, '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,
|
||||
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user