@@ -64,7 +64,7 @@ impl<'a, 'tcx> AvailableLocals {
64
64
& self ,
65
65
local : Local ,
66
66
location : Location ,
67
- ) -> LocalWithLocationIndex {
67
+ ) -> Option < LocalWithLocationIndex > {
68
68
self . local_with_location_map . local_with_specific_location ( local, Some ( location) )
69
69
}
70
70
@@ -103,7 +103,9 @@ impl AnalysisDomain<'tcx> for AvailableLocals {
103
103
104
104
// only the function parameters are available
105
105
for arg in body. args_iter ( ) {
106
- state. 0 . insert ( self . local_with_location_map . local_with_specific_location ( arg, None ) ) ;
106
+ if let Some ( l) = self . local_with_location_map . local_with_specific_location ( arg, None ) {
107
+ state. 0 . insert ( l) ;
108
+ }
107
109
}
108
110
}
109
111
}
@@ -197,14 +199,10 @@ impl LocalWithLocationMap {
197
199
& self ,
198
200
local : Local ,
199
201
location : Option < Location > ,
200
- ) -> LocalWithLocationIndex {
202
+ ) -> Option < LocalWithLocationIndex > {
201
203
debug ! ( "Looking for {:?} in {:?}" , ( local, location) , self . 0 ) ;
202
- let locations = self . 0 . get ( & local) . unwrap ( ) ;
203
- * locations
204
- . iter ( )
205
- . find ( |( _, l) | * l == location)
206
- . map ( |( location_idx, _) | location_idx)
207
- . unwrap ( )
204
+ let locations = self . 0 . get ( & local) ?;
205
+ locations. iter ( ) . find ( |( _, l) | * l == location) . map ( |( location_idx, _) | * location_idx)
208
206
}
209
207
210
208
fn local_with_locations (
@@ -281,10 +279,12 @@ where
281
279
_ => { }
282
280
}
283
281
284
- let index =
285
- self . local_with_location_map . local_with_specific_location ( local, Some ( location) ) ;
286
- debug ! ( "Inserting {:?} which corresponds to {:?}" , index, ( local, Some ( location) ) ) ;
287
- self . available . gen ( index) ;
282
+ if let Some ( index) =
283
+ self . local_with_location_map . local_with_specific_location ( local, Some ( location) )
284
+ {
285
+ debug ! ( "Inserting {:?} which corresponds to {:?}" , index, ( local, Some ( location) ) ) ;
286
+ self . available . gen ( index) ;
287
+ } ;
288
288
}
289
289
}
290
290
0 commit comments