@@ -32,45 +32,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for Cache {
3232 }
3333}
3434
35- macro_rules! get_predecessors {
36- ( mut $self: ident, $block: expr, $body: expr) => {
37- $self. predecessors_for( $block, $body)
38- } ;
39- ( $self: ident, $block: expr, $body: expr) => {
40- $self. unwrap_predecessors_for( $block)
41- } ;
42- }
43-
44- macro_rules! impl_predecessor_locations {
45- ( ( $( $pub: ident) ? ) $name: ident $( $mutability: ident) ?) => {
46- $( $pub) ? fn $name<' a>(
47- & ' a $( $mutability) ? self ,
48- loc: Location ,
49- body: & ' a Body <' a>
50- ) -> impl Iterator <Item = Location > + ' a {
51- let if_zero_locations = if loc. statement_index == 0 {
52- let predecessor_blocks = get_predecessors!( $( $mutability) ? self , loc. block, body) ;
53- let num_predecessor_blocks = predecessor_blocks. len( ) ;
54- Some (
55- ( 0 ..num_predecessor_blocks)
56- . map( move |i| predecessor_blocks[ i] )
57- . map( move |bb| body. terminator_loc( bb) ) ,
58- )
59- } else {
60- None
61- } ;
62-
63- let if_not_zero_locations = if loc. statement_index == 0 {
64- None
65- } else {
66- Some ( Location { block: loc. block, statement_index: loc. statement_index - 1 } )
67- } ;
68-
69- if_zero_locations. into_iter( ) . flatten( ) . chain( if_not_zero_locations)
70- }
71- } ;
72- }
73-
7435impl Cache {
7536 pub fn new ( ) -> Self {
7637 Self {
@@ -104,17 +65,35 @@ impl Cache {
10465 self . predecessors . as_ref ( ) . unwrap ( )
10566 }
10667
107- fn predecessors_for ( & mut self , bb : BasicBlock , body : & Body < ' _ > ) -> & [ BasicBlock ] {
108- & self . predecessors ( body) [ bb]
109- }
110-
11168 fn unwrap_predecessors_for ( & self , bb : BasicBlock ) -> & [ BasicBlock ] {
11269 & self . predecessors . as_ref ( ) . unwrap ( ) [ bb]
11370 }
11471
115- impl_predecessor_locations ! ( ( pub ) predecessor_locations mut ) ;
116-
117- impl_predecessor_locations ! ( ( ) unwrap_predecessor_locations) ;
72+ fn unwrap_predecessor_locations < ' a > (
73+ & ' a self ,
74+ loc : Location ,
75+ body : & ' a Body < ' a >
76+ ) -> impl Iterator < Item = Location > + ' a {
77+ let if_zero_locations = if loc. statement_index == 0 {
78+ let predecessor_blocks = self . unwrap_predecessors_for ( loc. block ) ;
79+ let num_predecessor_blocks = predecessor_blocks. len ( ) ;
80+ Some (
81+ ( 0 ..num_predecessor_blocks)
82+ . map ( move |i| predecessor_blocks[ i] )
83+ . map ( move |bb| body. terminator_loc ( bb) ) ,
84+ )
85+ } else {
86+ None
87+ } ;
88+
89+ let if_not_zero_locations = if loc. statement_index == 0 {
90+ None
91+ } else {
92+ Some ( Location { block : loc. block , statement_index : loc. statement_index - 1 } )
93+ } ;
94+
95+ if_zero_locations. into_iter ( ) . flatten ( ) . chain ( if_not_zero_locations)
96+ }
11897
11998 pub fn basic_blocks_mut < ' a , ' tcx > (
12099 & mut self ,
@@ -125,7 +104,6 @@ impl Cache {
125104 & mut body. basic_blocks
126105 }
127106
128- #[ inline]
129107 pub fn basic_blocks_and_local_decls_mut < ' a , ' tcx > (
130108 & mut self ,
131109 body : & ' a mut Body < ' tcx >
0 commit comments