@@ -22,7 +22,7 @@ use rustc_serialize::{
22
22
} ;
23
23
use rustc_session:: getopts;
24
24
use rustc_span:: {
25
- def_id:: { CrateNum , DefPathHash } ,
25
+ def_id:: { CrateNum , DefPathHash , LOCAL_CRATE } ,
26
26
edition:: Edition ,
27
27
BytePos , FileName , SourceFile ,
28
28
} ;
@@ -202,19 +202,23 @@ crate fn run(
202
202
203
203
// Collect CrateIds corresponding to provided target crates
204
204
// 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 < _ > > ( ) ;
211
211
let target_crates = options
212
212
. target_crates
213
213
. into_iter ( )
214
- . map ( find_crates_with_name )
214
+ . map ( |target| all_crates . iter ( ) . filter ( move | ( _ , name ) | name . as_str ( ) == target ) )
215
215
. flatten ( )
216
+ . map ( |( crate_num, _) | * * crate_num)
216
217
. collect :: < Vec < _ > > ( ) ;
217
218
219
+ debug ! ( "All crates in TyCtxt: {:?}" , all_crates) ;
220
+ debug ! ( "Scrape examples target_crates: {:?}" , target_crates) ;
221
+
218
222
// Run call-finder on all items
219
223
let mut calls = FxHashMap :: default ( ) ;
220
224
let mut finder = FindCalls { calls : & mut calls, tcx, map : tcx. hir ( ) , cx, target_crates } ;
0 commit comments