1 use rustc
::util
::nodemap
::DefIdSet
;
4 use crate::fold
::{DocFolder}
;
5 use crate::core
::DocContext
;
6 use crate::passes
::{ImplStripper, ImportStripper, Stripper, Pass}
;
8 pub const STRIP_PRIVATE
: Pass
=
9 Pass
::early("strip-private", strip_private
,
10 "strips all private items from a crate which cannot be seen externally, \
11 implies strip-priv-imports");
13 /// Strip private items from the point of view of a crate or externally from a
14 /// crate, specified by the `xcrate` flag.
15 pub fn strip_private(mut krate
: clean
::Crate
, cx
: &DocContext
<'_
, '_
, '_
>) -> clean
::Crate
{
16 // This stripper collects all *retained* nodes.
17 let mut retained
= DefIdSet
::default();
18 let access_levels
= cx
.renderinfo
.borrow().access_levels
.clone();
20 // strip all private items
22 let mut stripper
= Stripper
{
23 retained
: &mut retained
,
24 access_levels
: &access_levels
,
25 update_retained
: true,
27 krate
= ImportStripper
.fold_crate(stripper
.fold_crate(krate
));
30 // strip all impls referencing private items
31 let mut stripper
= ImplStripper { retained: &retained }
;
32 stripper
.fold_crate(krate
)