@@ -64,7 +64,7 @@ impl<'a, 'tcx> AvailableLocals {
6464 & self ,
6565 local : Local ,
6666 location : Location ,
67- ) -> LocalWithLocationIndex {
67+ ) -> Option < LocalWithLocationIndex > {
6868 self . local_with_location_map . local_with_specific_location ( local, Some ( location) )
6969 }
7070
@@ -103,7 +103,9 @@ impl AnalysisDomain<'tcx> for AvailableLocals {
103103
104104 // only the function parameters are available
105105 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+ }
107109 }
108110 }
109111}
@@ -197,14 +199,10 @@ impl LocalWithLocationMap {
197199 & self ,
198200 local : Local ,
199201 location : Option < Location > ,
200- ) -> LocalWithLocationIndex {
202+ ) -> Option < LocalWithLocationIndex > {
201203 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)
208206 }
209207
210208 fn local_with_locations (
@@ -281,10 +279,12 @@ where
281279 _ => { }
282280 }
283281
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+ } ;
288288 }
289289}
290290
0 commit comments