Properly restore within_fn_param value to the previous state

This commit is contained in:
Santiago Pastorino 2020-10-20 13:23:58 -03:00
parent a3470b13ab
commit 58018d438b
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF

View File

@ -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.