@@ -1365,39 +1365,39 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1365
1365
self . root . traits . decode ( self ) . map ( |index| self . local_def_id ( index) )
1366
1366
}
1367
1367
1368
- fn get_implementations_for_trait (
1368
+ fn get_trait_impls ( & ' a self ) -> impl Iterator < Item = ( DefId , Option < SimplifiedType > ) > + ' a {
1369
+ self . trait_impls . values ( ) . flat_map ( move |impls| {
1370
+ impls
1371
+ . decode ( self )
1372
+ . map ( |( idx, simplified_self_ty) | ( self . local_def_id ( idx) , simplified_self_ty) )
1373
+ } )
1374
+ }
1375
+
1376
+ fn get_implementations_of_trait (
1369
1377
& self ,
1370
1378
tcx : TyCtxt < ' tcx > ,
1371
- filter : Option < DefId > ,
1379
+ trait_def_id : DefId ,
1372
1380
) -> & ' tcx [ ( DefId , Option < SimplifiedType > ) ] {
1373
1381
if self . root . is_proc_macro_crate ( ) {
1374
1382
// proc-macro crates export no trait impls.
1375
1383
return & [ ] ;
1376
1384
}
1377
1385
1378
- if let Some ( def_id) = filter {
1379
- // Do a reverse lookup beforehand to avoid touching the crate_num
1380
- // hash map in the loop below.
1381
- let filter = match self . reverse_translate_def_id ( def_id) {
1382
- Some ( def_id) => ( def_id. krate . as_u32 ( ) , def_id. index ) ,
1383
- None => return & [ ] ,
1384
- } ;
1386
+ // Do a reverse lookup beforehand to avoid touching the crate_num
1387
+ // hash map in the loop below.
1388
+ let key = match self . reverse_translate_def_id ( trait_def_id) {
1389
+ Some ( def_id) => ( def_id. krate . as_u32 ( ) , def_id. index ) ,
1390
+ None => return & [ ] ,
1391
+ } ;
1385
1392
1386
- if let Some ( impls) = self . trait_impls . get ( & filter) {
1387
- tcx. arena . alloc_from_iter (
1388
- impls. decode ( self ) . map ( |( idx, simplified_self_ty) | {
1389
- ( self . local_def_id ( idx) , simplified_self_ty)
1390
- } ) ,
1391
- )
1392
- } else {
1393
- & [ ]
1394
- }
1395
- } else {
1396
- tcx. arena . alloc_from_iter ( self . trait_impls . values ( ) . flat_map ( |impls| {
1393
+ if let Some ( impls) = self . trait_impls . get ( & key) {
1394
+ tcx. arena . alloc_from_iter (
1397
1395
impls
1398
1396
. decode ( self )
1399
- . map ( |( idx, simplified_self_ty) | ( self . local_def_id ( idx) , simplified_self_ty) )
1400
- } ) )
1397
+ . map ( |( idx, simplified_self_ty) | ( self . local_def_id ( idx) , simplified_self_ty) ) ,
1398
+ )
1399
+ } else {
1400
+ & [ ]
1401
1401
}
1402
1402
}
1403
1403
0 commit comments