33//! FIXME: this might be better as a "generic" fixed-point combinator,
44//! but is not as ugly as it is right now.
55
6- use rustc:: mir:: { BasicBlock , Location } ;
7- use rustc_index:: bit_set:: BitIter ;
6+ #![ allow( unused) ]
87
98use crate :: borrow_check:: location:: LocationIndex ;
109
1110use crate :: borrow_check:: nll:: PoloniusOutput ;
1211
12+ use crate :: dataflow:: generic:: ResultsCursor ;
1313use crate :: dataflow:: indexes:: BorrowIndex ;
1414use crate :: dataflow:: move_paths:: HasMoveData ;
1515use crate :: dataflow:: Borrows ;
1616use crate :: dataflow:: EverInitializedPlaces ;
1717use crate :: dataflow:: MaybeUninitializedPlaces ;
18- use crate :: dataflow:: { FlowAtLocation , FlowsAtLocation } ;
1918use either:: Either ;
2019use std:: fmt;
2120use std:: rc:: Rc ;
2221
2322crate 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 > > ,
2726
2827 /// Polonius Output
2928 pub polonius_output : Option < Rc < PoloniusOutput > > ,
3029}
3130
3231impl < ' b , ' tcx > Flows < ' b , ' tcx > {
3332 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 > > ,
3736 polonius_output : Option < Rc < PoloniusOutput > > ,
3837 ) -> Self {
3938 Flows { borrows, uninits, ever_inits, polonius_output }
@@ -46,43 +45,9 @@ impl<'b, 'tcx> Flows<'b, 'tcx> {
4645 if let Some ( ref polonius) = self . polonius_output {
4746 Either :: Left ( polonius. errors_at ( location) . iter ( ) . cloned ( ) )
4847 } else {
49- Either :: Right ( self . borrows . iter_incoming ( ) )
48+ Either :: Right ( self . borrows . get ( ) . iter ( ) )
5049 }
5150 }
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- }
8651}
8752
8853impl < ' b , ' tcx > fmt:: Display for Flows < ' b , ' tcx > {
@@ -91,48 +56,50 @@ impl<'b, 'tcx> fmt::Display for Flows<'b, 'tcx> {
9156
9257 s. push_str ( "borrows in effect: [" ) ;
9358 let mut saw_one = false ;
94- self . borrows . each_state_bit ( |borrow| {
59+ self . borrows . get ( ) . iter ( ) . for_each ( |borrow| {
9560 if saw_one {
9661 s. push_str ( ", " ) ;
9762 } ;
9863 saw_one = true ;
99- let borrow_data = & self . borrows . operator ( ) . borrows ( ) [ borrow] ;
64+ let borrow_data = & self . borrows . analysis ( ) . borrows ( ) [ borrow] ;
10065 s. push_str ( & borrow_data. to_string ( ) ) ;
10166 } ) ;
10267 s. push_str ( "] " ) ;
10368
69+ /*
10470 s.push_str("borrows generated: [");
10571 let mut saw_one = false;
10672 self.borrows.each_gen_bit(|borrow| {
10773 if saw_one {
10874 s.push_str(", ");
10975 };
11076 saw_one = true;
111- let borrow_data = & self . borrows . operator ( ) . borrows ( ) [ borrow] ;
77+ let borrow_data = &self.borrows.analysis ().borrows()[borrow];
11278 s.push_str(&borrow_data.to_string());
11379 });
11480 s.push_str("] ");
81+ */
11582
11683 s. push_str ( "uninits: [" ) ;
11784 let mut saw_one = false ;
118- self . uninits . each_state_bit ( |mpi_uninit| {
85+ self . uninits . get ( ) . iter ( ) . for_each ( |mpi_uninit| {
11986 if saw_one {
12087 s. push_str ( ", " ) ;
12188 } ;
12289 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] ;
12491 s. push_str ( & move_path. to_string ( ) ) ;
12592 } ) ;
12693 s. push_str ( "] " ) ;
12794
12895 s. push_str ( "ever_init: [" ) ;
12996 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| {
13198 if saw_one {
13299 s. push_str ( ", " ) ;
133100 } ;
134101 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] ;
136103 s. push_str ( & format ! ( "{:?}" , ever_init) ) ;
137104 } ) ;
138105 s. push_str ( "]" ) ;
0 commit comments