1616//! liveness code so that it only operates over variables with regions in their
1717//! types, instead of all variables.
1818
19+ use rustc:: mir:: { Local , Mir } ;
1920use rustc:: ty:: TypeFoldable ;
2021use rustc_data_structures:: indexed_vec:: IndexVec ;
21- use rustc:: mir:: { Mir , Local } ;
2222use util:: liveness:: LiveVariableMap ;
2323
2424use rustc_data_structures:: indexed_vec:: Idx ;
@@ -32,11 +32,9 @@ crate struct NllLivenessMap {
3232 pub from_local : IndexVec < Local , Option < LocalWithRegion > > ,
3333 /// For each LocalWithRegion, maps back to the original Local index.
3434 pub to_local : IndexVec < LocalWithRegion , Local > ,
35-
3635}
3736
3837impl LiveVariableMap for NllLivenessMap {
39-
4038 fn from_local ( & self , local : Local ) -> Option < Self :: LiveVar > {
4139 self . from_local [ local]
4240 }
@@ -57,19 +55,21 @@ impl NllLivenessMap {
5755 /// regions a LocalWithRegion index. Returns a map for converting back and forth.
5856 pub fn compute ( mir : & Mir ) -> Self {
5957 let mut to_local = IndexVec :: default ( ) ;
60- let from_local: IndexVec < Local , Option < _ > > = mir
61- . local_decls
58+ let from_local: IndexVec < Local , Option < _ > > = mir. local_decls
6259 . iter_enumerated ( )
6360 . map ( |( local, local_decl) | {
6461 if local_decl. ty . has_free_regions ( ) {
6562 Some ( to_local. push ( local) )
63+ } else {
64+ None
6665 }
67- else {
68- None
69- }
70- } ) . collect ( ) ;
66+ } )
67+ . collect ( ) ;
7168
72- Self { from_local, to_local }
69+ Self {
70+ from_local,
71+ to_local,
72+ }
7373 }
7474}
7575
0 commit comments