about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-10-24 21:59:42 +0200
committerRalf Jung <post@ralfj.de>2018-10-29 09:16:27 +0100
commitf2f0f1a0a86ce658e1e037b4aece6d54ab1f7aa7 (patch)
tree6bceaf874ceb4bc372764acb98100ef9ff66a88f
parentc5abbd4be360cb433a84d86aa6d7cc6e63258a3b (diff)
downloadrust-f2f0f1a0a86ce658e1e037b4aece6d54ab1f7aa7.tar.gz
rust-f2f0f1a0a86ce658e1e037b4aece6d54ab1f7aa7.zip
fix nits
-rw-r--r--src/librustc/mir/mod.rs12
-rw-r--r--src/librustc_mir/transform/add_retag.rs9
2 files changed, 15 insertions, 6 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index d299f0e3b12..636fe115746 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -1755,12 +1755,16 @@ pub enum StatementKind<'tcx> {
     },
 
     /// Retag references in the given place, ensuring they got fresh tags.  This is
-    /// part of the Stacked Borrows model. `fn_entry` indicates whether this
-    /// is the initial retag that happens in the function prolog. These statements are
-    /// currently only interpreted by miri and only generated when "-Z mir-emit-retag" is passed.
+    /// part of the Stacked Borrows model. These statements are currently only interpreted
+    /// by miri and only generated when "-Z mir-emit-retag" is passed.
     /// See <https://internals.rust-lang.org/t/stacked-borrows-an-aliasing-model-for-rust/8153/>
     /// for more details.
-    Retag { fn_entry: bool, place: Place<'tcx> },
+    Retag {
+        /// `fn_entry` indicates whether this is the initial retag that happens in the
+        /// function prolog.
+        fn_entry: bool,
+        place: Place<'tcx>,
+    },
 
     /// Mark one terminating point of a region scope (i.e. static region).
     /// (The starting point(s) arise implicitly from borrows.)
diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs
index 0f16e29aae9..a50011cf5a1 100644
--- a/src/librustc_mir/transform/add_retag.rs
+++ b/src/librustc_mir/transform/add_retag.rs
@@ -42,7 +42,12 @@ fn is_local<'tcx>(
                     // (a local storing the array index, the current value of
                     // the projection base), so we stop tracking here.
                     false,
-                _ => is_local(&proj.base),
+                ProjectionElem::Field { .. } |
+                ProjectionElem::ConstantIndex { .. } |
+                ProjectionElem::Subslice { .. } |
+                ProjectionElem::Downcast { .. } =>
+                    // These just offset by a constant, entirely independent of everything else.
+                    is_local(&proj.base),
             }
         }
     }
@@ -121,7 +126,7 @@ impl MirPass for AddRetag {
                 Some(Terminator { kind: TerminatorKind::Call { ref destination, .. },
                                   source_info }) => {
                     // Remember the return destination for later
-                    if let &Some(ref destination) = destination {
+                    if let Some(ref destination) = destination {
                         if needs_retag(&destination.0) {
                             returns.push((source_info, destination.0.clone(), destination.1));
                         }