@@ -62,11 +62,14 @@ impl<'a, 'tcx> AvailableLocals {
62
62
63
63
/// Returns whether the given local is available at the given state
64
64
pub fn is_available ( & self , local : Local , state : & ' a State ) -> bool {
65
- self . local_with_location_map . local_with_locations ( local) . any (
66
- |place_taken_ref_local_with_location| {
65
+ let locations_opt = self . local_with_location_map . local_with_locations ( local) ;
66
+ if let Some ( mut locations) = locations_opt {
67
+ locations. any ( |place_taken_ref_local_with_location| {
67
68
state. 0 . contains ( place_taken_ref_local_with_location)
68
- } ,
69
- )
69
+ } )
70
+ } else {
71
+ false
72
+ }
70
73
}
71
74
72
75
fn transfer_function < T > ( & ' a self , available : & ' a mut T ) -> TransferFunction < ' a , T >
@@ -160,7 +163,7 @@ impl LocalWithLocationMap {
160
163
. or_insert ( SmallVec :: with_capacity ( 2 ) )
161
164
. push ( ( 0usize . into ( ) , None ) ) ;
162
165
163
- for arg in body. args_iter ( ) . chain ( body . vars_and_temps_iter ( ) ) {
166
+ for arg in body. args_iter ( ) {
164
167
map. entry ( arg) . or_insert ( SmallVec :: with_capacity ( 2 ) ) . push ( ( 0usize . into ( ) , None ) ) ;
165
168
}
166
169
@@ -196,10 +199,10 @@ impl LocalWithLocationMap {
196
199
fn local_with_locations (
197
200
& self ,
198
201
local : Local ,
199
- ) -> impl Iterator < Item = LocalWithLocationIndex > + ' _ {
202
+ ) -> Option < impl Iterator < Item = LocalWithLocationIndex > + ' _ > {
200
203
debug ! ( "Looking for {:?} in {:?}" , local, self . 0 ) ;
201
- let locations = self . 0 . get ( & local) . unwrap ( ) ;
202
- return locations. iter ( ) . map ( move |( location_idx, _) | * location_idx) ;
204
+ let locations = self . 0 . get ( & local) ? ;
205
+ return Some ( locations. iter ( ) . map ( move |( location_idx, _) | * location_idx) ) ;
203
206
}
204
207
205
208
fn len ( & self ) -> usize {
@@ -261,9 +264,13 @@ where
261
264
T : GenKill < LocalWithLocationIndex > ,
262
265
{
263
266
fn invalidate_local ( & mut self , local_invalidated : Local , _location : Location ) {
264
- for x in self . local_with_location_map . local_with_locations ( local_invalidated) {
265
- debug ! ( "Invalidating {:?} which corresponds to {:?}" , x, local_invalidated) ;
266
- self . available . kill ( x) ;
267
+ if let Some ( locations) =
268
+ self . local_with_location_map . local_with_locations ( local_invalidated)
269
+ {
270
+ for x in locations {
271
+ debug ! ( "Invalidating {:?} which corresponds to {:?}" , x, local_invalidated) ;
272
+ self . available . kill ( x) ;
273
+ }
267
274
}
268
275
}
269
276
@@ -278,9 +285,15 @@ where
278
285
279
286
let all_participating_alive =
280
287
rvalue. participating_locals ( location) . all ( |participating_local| {
281
- self . local_with_location_map
282
- . local_with_locations ( participating_local)
283
- . any ( |participating_local_idx| self . available . is_alive ( participating_local_idx) )
288
+ let location_opt =
289
+ self . local_with_location_map . local_with_locations ( participating_local) ;
290
+ if let Some ( mut locations) = location_opt {
291
+ locations. any ( |participating_local_idx| {
292
+ self . available . is_alive ( participating_local_idx)
293
+ } )
294
+ } else {
295
+ false
296
+ }
284
297
} ) ;
285
298
if all_participating_alive {
286
299
let index =
0 commit comments