Skip to content

Commit 24a71cb

Browse files
committed
Fix local crate not being scraped
1 parent b1616f3 commit 24a71cb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/librustdoc/scrape_examples.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_serialize::{
2222
};
2323
use rustc_session::getopts;
2424
use 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

Comments
 (0)