]> git.lizzy.rs Git - rust.git/commitdiff
don't walk MIR if no local variables need liveness
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 10 Aug 2018 08:17:46 +0000 (04:17 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 10 Aug 2018 08:17:46 +0000 (04:17 -0400)
This is true for tuple-stress and html5ever

src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs

index 20bf53f4d953b9ff05202a5d17a9809116ca1931..89e8c76b22fb456ed31ec645f7e6b253c9d254f7 100644 (file)
@@ -86,6 +86,11 @@ impl NllLivenessMap {
             to_local,
         }
     }
+
+    /// True if there are no local variables that need liveness computation.
+    crate fn is_empty(&self) -> bool {
+        self.to_local.is_empty()
+    }
 }
 
 /// Index given to each local variable whose type contains a region.
index d3ef2a369094a733964b9839def3885fc6e4e684..a9b69cfe761abc4dded3ee3da2ab797dc9b55b72 100644 (file)
@@ -55,7 +55,7 @@ pub(super) fn generate<'gcx, 'tcx>(
     let liveness = LivenessResults::compute(mir, &liveness_map);
 
     // For everything else, it is only live where it is actually used.
-    {
+    if !liveness_map.is_empty() {
         let mut generator = TypeLivenessGenerator {
             cx,
             mir,