]> git.lizzy.rs Git - rust.git/commitdiff
inject fake read in binding pattern with ascription
authorRemy Rakic <remy.rakic@gmail.com>
Thu, 13 Sep 2018 15:06:41 +0000 (17:06 +0200)
committerRemy Rakic <remy.rakic@gmail.com>
Tue, 18 Sep 2018 12:34:51 +0000 (14:34 +0200)
src/librustc_mir/build/matches/mod.rs

index 6a84658a7a9872d837b80e0382a9e5f51bf95c4b..91d439d430c2ce992eb34f41d775844bda15e994 100644 (file)
@@ -267,7 +267,7 @@ pub fn expr_into_pattern(
 
                 // Inject a fake read of the newly created binding
                 // to test the fallout of fixing issue #53695 where NLL
-                // allows to create variables that are immediately unusable.
+                // allows creating unused variables that are effectively unusable.
                 let source_info = self.source_info(irrefutable_pat.span);
                 self.cfg.push(
                     block,
@@ -318,6 +318,17 @@ pub fn expr_into_pattern(
                     },
                 );
 
+                // Inject a fake read of the newly created binding
+                // to test the fallout of fixing issue #53695 where NLL
+                // allows creating unused variables that are effectively unusable.
+                self.cfg.push(
+                    block,
+                    Statement {
+                        source_info,
+                        kind: StatementKind::ReadForMatch(place.clone()),
+                    },
+                );
+
                 self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
                 block.unit()
             }