1use rustc_hir::def_id::DefIdSet;
23use crate::clean::{self, Import, ImportSource, Item};
4use crate::fold::DocFolder;
56/// Get the id's of all items that are `pub use`d in the crate.
7///
8/// We need this to know if a stripped module is `pub use mod::*`, to decide
9/// if it needs to be kept in the index, despite being stripped.
10///
11/// See [#100973](https://github.com/rust-lang/rust/issues/100973) and
12/// [#101103](https://github.com/rust-lang/rust/issues/101103) for times when
13/// this information is needed.
14pub(crate) fn get_imports(krate: clean::Crate) -> (clean::Crate, DefIdSet) {
15let mut finder = ImportFinder::default();
16let krate = finder.fold_crate(krate);
17 (krate, finder.imported)
18}
1920#[derive(Default)]
21struct ImportFinder {
22 imported: DefIdSet,
23}
2425impl DocFolder for ImportFinder {
26fn fold_item(&mut self, i: Item) -> Option<Item> {
27match i.kind {
28 clean::ImportItem(Import { source: ImportSource { did: Some(did), .. }, .. }) => {
29self.imported.insert(did);
30Some(i)
31 }
3233_ => Some(self.fold_item_recur(i)),
34 }
35 }
36}