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