Skip to content

Commit 58018d4

Browse files
committed
Properly restore within_fn_param value to the previous state
1 parent a3470b1 commit 58018d4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_typeck/src/check/gather_locals.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKi
66
use rustc_middle::ty::Ty;
77
use rustc_span::Span;
88
use rustc_trait_selection::traits;
9+
use std::mem;
910

1011
pub(super) struct GatherLocalsVisitor<'a, 'tcx> {
1112
fcx: &'a FnCtxt<'a, 'tcx>,
@@ -97,9 +98,9 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
9798
}
9899

99100
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
100-
self.within_fn_param = true;
101+
let old_within_fn_param = mem::replace(&mut self.within_fn_param, true);
101102
intravisit::walk_param(self, param);
102-
self.within_fn_param = false;
103+
self.within_fn_param = old_within_fn_param;
103104
}
104105

105106
// Add pattern bindings.

0 commit comments

Comments
 (0)