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 cbd9c9a4e1a8..e564118197fe 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 @@ -16,9 +16,9 @@ //! liveness code so that it only operates over variables with regions in their //! types, instead of all variables. +use rustc::mir::{Local, Mir}; use rustc::ty::TypeFoldable; use rustc_data_structures::indexed_vec::IndexVec; -use rustc::mir::{Mir, Local}; use util::liveness::LiveVariableMap; use rustc_data_structures::indexed_vec::Idx; @@ -32,11 +32,9 @@ crate struct NllLivenessMap { pub from_local: IndexVec>, /// For each LocalWithRegion, maps back to the original Local index. pub to_local: IndexVec, - } impl LiveVariableMap for NllLivenessMap { - fn from_local(&self, local: Local) -> Option { self.from_local[local] } @@ -57,19 +55,21 @@ impl NllLivenessMap { /// regions a LocalWithRegion index. Returns a map for converting back and forth. pub fn compute(mir: &Mir) -> Self { let mut to_local = IndexVec::default(); - let from_local: IndexVec> = mir - .local_decls + let from_local: IndexVec> = mir.local_decls .iter_enumerated() .map(|(local, local_decl)| { if local_decl.ty.has_free_regions() { Some(to_local.push(local)) + } else { + None } - else { - None - } - }).collect(); + }) + .collect(); - Self { from_local, to_local } + Self { + from_local, + to_local, + } } }