16
16
//! liveness code so that it only operates over variables with regions in their
17
17
//! types, instead of all variables.
18
18
19
+ use rustc:: mir:: { Local , Mir } ;
19
20
use rustc:: ty:: TypeFoldable ;
20
21
use rustc_data_structures:: indexed_vec:: IndexVec ;
21
- use rustc:: mir:: { Mir , Local } ;
22
22
use util:: liveness:: LiveVariableMap ;
23
23
24
24
use rustc_data_structures:: indexed_vec:: Idx ;
@@ -32,11 +32,9 @@ crate struct NllLivenessMap {
32
32
pub from_local : IndexVec < Local , Option < LocalWithRegion > > ,
33
33
/// For each LocalWithRegion, maps back to the original Local index.
34
34
pub to_local : IndexVec < LocalWithRegion , Local > ,
35
-
36
35
}
37
36
38
37
impl LiveVariableMap for NllLivenessMap {
39
-
40
38
fn from_local ( & self , local : Local ) -> Option < Self :: LiveVar > {
41
39
self . from_local [ local]
42
40
}
@@ -57,19 +55,21 @@ impl NllLivenessMap {
57
55
/// regions a LocalWithRegion index. Returns a map for converting back and forth.
58
56
pub fn compute ( mir : & Mir ) -> Self {
59
57
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
62
59
. iter_enumerated ( )
63
60
. map ( |( local, local_decl) | {
64
61
if local_decl. ty . has_free_regions ( ) {
65
62
Some ( to_local. push ( local) )
63
+ } else {
64
+ None
66
65
}
67
- else {
68
- None
69
- }
70
- } ) . collect ( ) ;
66
+ } )
67
+ . collect ( ) ;
71
68
72
- Self { from_local, to_local }
69
+ Self {
70
+ from_local,
71
+ to_local,
72
+ }
73
73
}
74
74
}
75
75
0 commit comments