Skip to content

Commit 97da1c9

Browse files
committed
Correct binding scope when building MIR.
1 parent a3a436e commit 97da1c9

File tree

1 file changed

+3
-0
lines changed
  • compiler/rustc_mir_build/src/builder/matches

1 file changed

+3
-0
lines changed

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
741741
pattern,
742742
&ProjectedUserTypesNode::None,
743743
&mut |this, name, mode, var, span, ty, user_tys| {
744+
let saved_scope = this.source_scope;
745+
this.set_correct_source_scope_for_arg(var.0, saved_scope, span);
744746
let vis_scope = *visibility_scope
745747
.get_or_insert_with(|| this.new_source_scope(scope_span, LintLevel::Inherited));
746748
let source_info = SourceInfo { span, scope: this.source_scope };
@@ -758,6 +760,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
758760
opt_match_place.map(|(x, y)| (x.cloned(), y)),
759761
pattern.span,
760762
);
763+
this.source_scope = saved_scope;
761764
},
762765
);
763766
if let Some(guard_expr) = guard {

0 commit comments

Comments
 (0)