@@ -16,7 +16,7 @@ use rustc_span::source_map::{SourceMap, Spanned};
16
16
use rustc_span:: symbol:: { kw, sym, Symbol } ;
17
17
use rustc_span:: { MultiSpan , Span , DUMMY_SP } ;
18
18
use rustc_target:: spec:: abi:: Abi ;
19
- use syntax:: ast:: { self , AsmDialect , CrateSugar , Ident , Name , NodeId } ;
19
+ use syntax:: ast:: { self , AsmDialect , CrateSugar , Ident , Name } ;
20
20
use syntax:: ast:: { AttrVec , Attribute , FloatTy , IntTy , Label , LitKind , StrStyle , UintTy } ;
21
21
pub use syntax:: ast:: { BorrowKind , ImplPolarity , IsAuto } ;
22
22
pub use syntax:: ast:: { CaptureBy , Movability , Mutability } ;
@@ -2608,13 +2608,24 @@ pub type CaptureModeMap = NodeMap<CaptureBy>;
2608
2608
// has length > 0 if the trait is found through an chain of imports, starting with the
2609
2609
// import/use statement in the scope where the trait is used.
2610
2610
#[ derive( Clone , Debug ) ]
2611
- pub struct TraitCandidate {
2611
+ pub struct TraitCandidate < ID = HirId > {
2612
2612
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
+ }
2614
2625
}
2615
2626
2616
2627
// Trait method resolution
2617
- pub type TraitMap = NodeMap < Vec < TraitCandidate > > ;
2628
+ pub type TraitMap < ID = HirId > = NodeMap < Vec < TraitCandidate < ID > > > ;
2618
2629
2619
2630
// Map from the NodeId of a glob import to a list of items which are actually
2620
2631
// imported.
0 commit comments