1 use rustc_data_structures::fx::FxHashSet;
2 use rustc_hir::def_id::DefId;
5 clean::{self, Import, ImportSource, Item},
9 /// Get the id's of all items that are `pub use`d in the crate.
11 /// We need this to know if a stripped module is `pub use mod::*`, to decide
12 /// if it needs to be kept in the index, despite being stripped.
14 /// See [#100973](https://github.com/rust-lang/rust/issues/100973) and
15 /// [#101103](https://github.com/rust-lang/rust/issues/101103) for times when
16 /// this information is needed.
17 pub(crate) fn get_imports(krate: clean::Crate) -> (clean::Crate, FxHashSet<DefId>) {
18 let mut finder = ImportFinder { imported: FxHashSet::default() };
19 let krate = finder.fold_crate(krate);
20 (krate, finder.imported)
24 imported: FxHashSet<DefId>,
27 impl DocFolder for ImportFinder {
28 fn fold_item(&mut self, i: Item) -> Option<Item> {
30 clean::ImportItem(Import { source: ImportSource { did: Some(did), .. }, .. }) => {
31 self.imported.insert(did);
35 _ => Some(self.fold_item_recur(i)),