Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c3c7a5b

Browse files
committed
inject fake read in binding pattern with ascription
1 parent 7216012 commit c3c7a5b

File tree

1 file changed

+12
-1
lines changed
  • src/librustc_mir/build/matches

1 file changed

+12
-1
lines changed

src/librustc_mir/build/matches/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
267267

268268
// Inject a fake read of the newly created binding
269269
// to test the fallout of fixing issue #53695 where NLL
270-
// allows to create variables that are immediately unusable.
270+
// allows creating unused variables that are effectively unusable.
271271
let source_info = self.source_info(irrefutable_pat.span);
272272
self.cfg.push(
273273
block,
@@ -318,6 +318,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
318318
},
319319
);
320320

321+
// Inject a fake read of the newly created binding
322+
// to test the fallout of fixing issue #53695 where NLL
323+
// allows creating unused variables that are effectively unusable.
324+
self.cfg.push(
325+
block,
326+
Statement {
327+
source_info,
328+
kind: StatementKind::ReadForMatch(place.clone()),
329+
},
330+
);
331+
321332
self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
322333
block.unit()
323334
}

0 commit comments

Comments
 (0)