From 58018d438b3e14624bf33a9c0d2031e906797b8d Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 20 Oct 2020 13:23:58 -0300 Subject: [PATCH] Properly restore within_fn_param value to the previous state --- compiler/rustc_typeck/src/check/gather_locals.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/check/gather_locals.rs b/compiler/rustc_typeck/src/check/gather_locals.rs index d5e45c3b89f..8699de4ce14 100644 --- a/compiler/rustc_typeck/src/check/gather_locals.rs +++ b/compiler/rustc_typeck/src/check/gather_locals.rs @@ -6,6 +6,7 @@ use rustc_middle::ty::Ty; use rustc_span::Span; use rustc_trait_selection::traits; +use std::mem; pub(super) struct GatherLocalsVisitor<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, @@ -97,9 +98,9 @@ fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) { } fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) { - self.within_fn_param = true; + let old_within_fn_param = mem::replace(&mut self.within_fn_param, true); intravisit::walk_param(self, param); - self.within_fn_param = false; + self.within_fn_param = old_within_fn_param; } // Add pattern bindings.