3
3
//! FIXME: this might be better as a "generic" fixed-point combinator,
4
4
//! but is not as ugly as it is right now.
5
5
6
- use rustc:: mir:: { BasicBlock , Location } ;
7
- use rustc_index:: bit_set:: BitIter ;
8
-
9
6
use crate :: borrow_check:: location:: LocationIndex ;
10
7
11
8
use crate :: borrow_check:: nll:: PoloniusOutput ;
12
9
10
+ use crate :: dataflow:: generic:: ResultsCursor ;
13
11
use crate :: dataflow:: indexes:: BorrowIndex ;
14
12
use crate :: dataflow:: move_paths:: HasMoveData ;
15
13
use crate :: dataflow:: Borrows ;
16
14
use crate :: dataflow:: EverInitializedPlaces ;
17
15
use crate :: dataflow:: MaybeUninitializedPlaces ;
18
- use crate :: dataflow:: { FlowAtLocation , FlowsAtLocation } ;
19
16
use either:: Either ;
20
17
use std:: fmt;
21
18
use std:: rc:: Rc ;
22
19
23
20
crate struct Flows < ' b , ' tcx > {
24
- borrows : FlowAtLocation < ' tcx , Borrows < ' b , ' tcx > > ,
25
- pub uninits : FlowAtLocation < ' tcx , MaybeUninitializedPlaces < ' b , ' tcx > > ,
26
- pub ever_inits : FlowAtLocation < ' tcx , EverInitializedPlaces < ' b , ' tcx > > ,
21
+ pub borrows : ResultsCursor < ' b , ' tcx , Borrows < ' b , ' tcx > > ,
22
+ pub uninits : ResultsCursor < ' b , ' tcx , MaybeUninitializedPlaces < ' b , ' tcx > > ,
23
+ pub ever_inits : ResultsCursor < ' b , ' tcx , EverInitializedPlaces < ' b , ' tcx > > ,
27
24
28
25
/// Polonius Output
29
26
pub polonius_output : Option < Rc < PoloniusOutput > > ,
30
27
}
31
28
32
29
impl < ' b , ' tcx > Flows < ' b , ' tcx > {
33
30
crate fn new (
34
- borrows : FlowAtLocation < ' tcx , Borrows < ' b , ' tcx > > ,
35
- uninits : FlowAtLocation < ' tcx , MaybeUninitializedPlaces < ' b , ' tcx > > ,
36
- ever_inits : FlowAtLocation < ' tcx , EverInitializedPlaces < ' b , ' tcx > > ,
31
+ borrows : ResultsCursor < ' b , ' tcx , Borrows < ' b , ' tcx > > ,
32
+ uninits : ResultsCursor < ' b , ' tcx , MaybeUninitializedPlaces < ' b , ' tcx > > ,
33
+ ever_inits : ResultsCursor < ' b , ' tcx , EverInitializedPlaces < ' b , ' tcx > > ,
37
34
polonius_output : Option < Rc < PoloniusOutput > > ,
38
35
) -> Self {
39
36
Flows { borrows, uninits, ever_inits, polonius_output }
@@ -46,43 +43,9 @@ impl<'b, 'tcx> Flows<'b, 'tcx> {
46
43
if let Some ( ref polonius) = self . polonius_output {
47
44
Either :: Left ( polonius. errors_at ( location) . iter ( ) . cloned ( ) )
48
45
} else {
49
- Either :: Right ( self . borrows . iter_incoming ( ) )
46
+ Either :: Right ( self . borrows . get ( ) . iter ( ) )
50
47
}
51
48
}
52
-
53
- crate fn with_outgoing_borrows ( & self , op : impl FnOnce ( BitIter < ' _ , BorrowIndex > ) ) {
54
- self . borrows . with_iter_outgoing ( op)
55
- }
56
- }
57
-
58
- macro_rules! each_flow {
59
- ( $this: ident, $meth: ident( $arg: ident) ) => {
60
- FlowAtLocation :: $meth( & mut $this. borrows, $arg) ;
61
- FlowAtLocation :: $meth( & mut $this. uninits, $arg) ;
62
- FlowAtLocation :: $meth( & mut $this. ever_inits, $arg) ;
63
- } ;
64
- }
65
-
66
- impl < ' b , ' tcx > FlowsAtLocation for Flows < ' b , ' tcx > {
67
- fn reset_to_entry_of ( & mut self , bb : BasicBlock ) {
68
- each_flow ! ( self , reset_to_entry_of( bb) ) ;
69
- }
70
-
71
- fn reset_to_exit_of ( & mut self , bb : BasicBlock ) {
72
- each_flow ! ( self , reset_to_exit_of( bb) ) ;
73
- }
74
-
75
- fn reconstruct_statement_effect ( & mut self , location : Location ) {
76
- each_flow ! ( self , reconstruct_statement_effect( location) ) ;
77
- }
78
-
79
- fn reconstruct_terminator_effect ( & mut self , location : Location ) {
80
- each_flow ! ( self , reconstruct_terminator_effect( location) ) ;
81
- }
82
-
83
- fn apply_local_effect ( & mut self , location : Location ) {
84
- each_flow ! ( self , apply_local_effect( location) ) ;
85
- }
86
49
}
87
50
88
51
impl < ' b , ' tcx > fmt:: Display for Flows < ' b , ' tcx > {
@@ -91,48 +54,50 @@ impl<'b, 'tcx> fmt::Display for Flows<'b, 'tcx> {
91
54
92
55
s. push_str ( "borrows in effect: [" ) ;
93
56
let mut saw_one = false ;
94
- self . borrows . each_state_bit ( |borrow| {
57
+ self . borrows . get ( ) . iter ( ) . for_each ( |borrow| {
95
58
if saw_one {
96
59
s. push_str ( ", " ) ;
97
60
} ;
98
61
saw_one = true ;
99
- let borrow_data = & self . borrows . operator ( ) . borrows ( ) [ borrow] ;
62
+ let borrow_data = & self . borrows . analysis ( ) . borrows ( ) [ borrow] ;
100
63
s. push_str ( & borrow_data. to_string ( ) ) ;
101
64
} ) ;
102
65
s. push_str ( "] " ) ;
103
66
67
+ /*
104
68
s.push_str("borrows generated: [");
105
69
let mut saw_one = false;
106
70
self.borrows.each_gen_bit(|borrow| {
107
71
if saw_one {
108
72
s.push_str(", ");
109
73
};
110
74
saw_one = true;
111
- let borrow_data = & self . borrows . operator ( ) . borrows ( ) [ borrow] ;
75
+ let borrow_data = &self.borrows.analysis ().borrows()[borrow];
112
76
s.push_str(&borrow_data.to_string());
113
77
});
114
78
s.push_str("] ");
79
+ */
115
80
116
81
s. push_str ( "uninits: [" ) ;
117
82
let mut saw_one = false ;
118
- self . uninits . each_state_bit ( |mpi_uninit| {
83
+ self . uninits . get ( ) . iter ( ) . for_each ( |mpi_uninit| {
119
84
if saw_one {
120
85
s. push_str ( ", " ) ;
121
86
} ;
122
87
saw_one = true ;
123
- let move_path = & self . uninits . operator ( ) . move_data ( ) . move_paths [ mpi_uninit] ;
88
+ let move_path = & self . uninits . analysis ( ) . move_data ( ) . move_paths [ mpi_uninit] ;
124
89
s. push_str ( & move_path. to_string ( ) ) ;
125
90
} ) ;
126
91
s. push_str ( "] " ) ;
127
92
128
93
s. push_str ( "ever_init: [" ) ;
129
94
let mut saw_one = false ;
130
- self . ever_inits . each_state_bit ( |mpi_ever_init| {
95
+ self . ever_inits . get ( ) . iter ( ) . for_each ( |mpi_ever_init| {
131
96
if saw_one {
132
97
s. push_str ( ", " ) ;
133
98
} ;
134
99
saw_one = true ;
135
- let ever_init = & self . ever_inits . operator ( ) . move_data ( ) . inits [ mpi_ever_init] ;
100
+ let ever_init = & self . ever_inits . analysis ( ) . move_data ( ) . inits [ mpi_ever_init] ;
136
101
s. push_str ( & format ! ( "{:?}" , ever_init) ) ;
137
102
} ) ;
138
103
s. push_str ( "]" ) ;
0 commit comments