@@ -22,7 +22,7 @@ use rustc_serialize::{
2222} ;
2323use rustc_session:: getopts;
2424use rustc_span:: {
25- def_id:: { CrateNum , DefPathHash } ,
25+ def_id:: { CrateNum , DefPathHash , LOCAL_CRATE } ,
2626 edition:: Edition ,
2727 BytePos , FileName , SourceFile ,
2828} ;
@@ -202,19 +202,23 @@ crate fn run(
202202
203203 // Collect CrateIds corresponding to provided target crates
204204 // If two different versions of the crate in the dependency tree, then examples will be collcted from both.
205- let find_crates_with_name = | target_crate : String | {
206- tcx . crates ( ( ) )
207- . iter ( )
208- . filter ( move |crate_num| tcx . crate_name ( * * crate_num ) . as_str ( ) == target_crate )
209- . copied ( )
210- } ;
205+ let all_crates = tcx
206+ . crates ( ( ) )
207+ . iter ( )
208+ . chain ( [ & LOCAL_CRATE ] )
209+ . map ( |crate_num| ( crate_num , tcx . crate_name ( * crate_num ) ) )
210+ . collect :: < Vec < _ > > ( ) ;
211211 let target_crates = options
212212 . target_crates
213213 . into_iter ( )
214- . map ( find_crates_with_name )
214+ . map ( |target| all_crates . iter ( ) . filter ( move | ( _ , name ) | name . as_str ( ) == target ) )
215215 . flatten ( )
216+ . map ( |( crate_num, _) | * * crate_num)
216217 . collect :: < Vec < _ > > ( ) ;
217218
219+ debug ! ( "All crates in TyCtxt: {:?}" , all_crates) ;
220+ debug ! ( "Scrape examples target_crates: {:?}" , target_crates) ;
221+
218222 // Run call-finder on all items
219223 let mut calls = FxHashMap :: default ( ) ;
220224 let mut finder = FindCalls { calls : & mut calls, tcx, map : tcx. hir ( ) , cx, target_crates } ;
0 commit comments