about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-02-15 07:17:49 +0900
committerGitHub <noreply@github.com>2020-02-15 07:17:49 +0900
commite0ea1e759f76b96a8a609b9690ecc3ddadbbcbb5 (patch)
treee1b7a70e2c66737dcfd1d1fe7aac68caad540438 /src
parent829a3635e45f59546e9b5ac0716ea9e0c694456c (diff)
parentebbaf4611a9605412d2aa31c8ebaf0745557fff0 (diff)
downloadrust-e0ea1e759f76b96a8a609b9690ecc3ddadbbcbb5.tar.gz
rust-e0ea1e759f76b96a8a609b9690ecc3ddadbbcbb5.zip
Rollup merge of #69051 - Centril:st-fixes, r=eddyb
simplify_try: address some of eddyb's comments

Addresses only https://github.com/rust-lang/rust/pull/66282#discussion_r376730986 and https://github.com/rust-lang/rust/pull/66282#discussion_r376730824.

r? @eddyb
cc @oli-obk
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/transform/simplify_try.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librustc_mir/transform/simplify_try.rs b/src/librustc_mir/transform/simplify_try.rs
index bd661195a48..3f28f033047 100644
--- a/src/librustc_mir/transform/simplify_try.rs
+++ b/src/librustc_mir/transform/simplify_try.rs
@@ -52,6 +52,8 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {
                 Some(x) => x,
             };
             if local_tmp_s0 != local_tmp_s1
+                // Avoid moving into ourselves.
+                || local_0 == local_1
                 // The field-and-variant information match up.
                 || vf_s0 != vf_s1
                 // Source and target locals have the same type.
@@ -64,6 +66,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {
             }
 
             // Right shape; transform!
+            s0.source_info = s2.source_info;
             match &mut s0.kind {
                 StatementKind::Assign(box (place, rvalue)) => {
                     *place = local_0.into();