@@ -1365,39 +1365,39 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13651365 self . root . traits . decode ( self ) . map ( |index| self . local_def_id ( index) )
13661366 }
13671367
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 (
13691377 & self ,
13701378 tcx : TyCtxt < ' tcx > ,
1371- filter : Option < DefId > ,
1379+ trait_def_id : DefId ,
13721380 ) -> & ' tcx [ ( DefId , Option < SimplifiedType > ) ] {
13731381 if self . root . is_proc_macro_crate ( ) {
13741382 // proc-macro crates export no trait impls.
13751383 return & [ ] ;
13761384 }
13771385
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+ } ;
13851392
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 (
13971395 impls
13981396 . 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+ & [ ]
14011401 }
14021402 }
14031403
0 commit comments