@@ -16,7 +16,7 @@ use rustc_span::source_map::{SourceMap, Spanned};
1616use rustc_span:: symbol:: { kw, sym, Symbol } ;
1717use rustc_span:: { MultiSpan , Span , DUMMY_SP } ;
1818use rustc_target:: spec:: abi:: Abi ;
19- use syntax:: ast:: { self , AsmDialect , CrateSugar , Ident , Name , NodeId } ;
19+ use syntax:: ast:: { self , AsmDialect , CrateSugar , Ident , Name } ;
2020use syntax:: ast:: { AttrVec , Attribute , FloatTy , IntTy , Label , LitKind , StrStyle , UintTy } ;
2121pub use syntax:: ast:: { BorrowKind , ImplPolarity , IsAuto } ;
2222pub use syntax:: ast:: { CaptureBy , Movability , Mutability } ;
@@ -2608,13 +2608,24 @@ pub type CaptureModeMap = NodeMap<CaptureBy>;
26082608// has length > 0 if the trait is found through an chain of imports, starting with the
26092609// import/use statement in the scope where the trait is used.
26102610#[ derive( Clone , Debug ) ]
2611- pub struct TraitCandidate {
2611+ pub struct TraitCandidate < ID = HirId > {
26122612 pub def_id : DefId ,
2613- pub import_ids : SmallVec < [ NodeId ; 1 ] > ,
2613+ pub import_ids : SmallVec < [ ID ; 1 ] > ,
2614+ }
2615+
2616+ impl < ID > TraitCandidate < ID > {
2617+ pub fn map_import_ids < F , T > ( self , f : F ) -> TraitCandidate < T >
2618+ where
2619+ F : Fn ( ID ) -> T ,
2620+ {
2621+ let TraitCandidate { def_id, import_ids } = self ;
2622+ let import_ids = import_ids. into_iter ( ) . map ( f) . collect ( ) ;
2623+ TraitCandidate { def_id, import_ids }
2624+ }
26142625}
26152626
26162627// Trait method resolution
2617- pub type TraitMap = NodeMap < Vec < TraitCandidate > > ;
2628+ pub type TraitMap < ID = HirId > = NodeMap < Vec < TraitCandidate < ID > > > ;
26182629
26192630// Map from the NodeId of a glob import to a list of items which are actually
26202631// imported.
0 commit comments