]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #107662 - cjgillot:copy-projection, r=oli-obk
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 7 Feb 2023 16:57:15 +0000 (17:57 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2023 16:57:15 +0000 (17:57 +0100)
Turn projections into copies in CopyProp.

The current implementation can leave behind projections that are moved out several times.

This PR widens the check to turn such moves into copies: a move out of a projection of a copy is equivalent to a copy of the original projection.

1  2 
tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir

index e338f15b4853144be1b1019369f36759a6572516,69d12bc2d5394e28255da860170f5d5e8777a94b..66ba4df767ccf2ff004604ac17d3070affa706c1
@@@ -34,9 -37,15 +34,9 @@@ fn ezmap(_1: Option<i32>) -> Option<i32
      }
  
      bb3: {
-         _4 = move ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
+         _4 = ((_1 as Some).0: i32);      // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
          StorageLive(_5);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        StorageLive(_6);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        _6 = (move _4,);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        StorageLive(_7);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        _7 = move (_6.0: i32);           // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        _5 = Add(_7, const 1_i32);       // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
 -        StorageDead(_7);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
 -        StorageDead(_6);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:28: 7:29
 +        _5 = Add(_4, const 1_i32);       // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
          _0 = Option::<i32>::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30
          StorageDead(_5);                 // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30
          goto -> bb4;                     // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2