diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs index 20bf53f4d953b..89e8c76b22fb4 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs @@ -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. diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index d3ef2a369094a..a9b69cfe761ab 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -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,