11use crate :: clean;
22use crate :: core:: DocContext ;
3- use crate :: fold:: { self , DocFolder } ;
43use crate :: html:: markdown:: { find_testable_code, ErrorCodes } ;
54use crate :: passes:: check_doc_test_visibility:: { should_have_doc_example, Tests } ;
65use crate :: passes:: Pass ;
6+ use crate :: visit:: DocVisitor ;
77use rustc_hir as hir;
88use rustc_lint:: builtin:: MISSING_DOCS ;
99use rustc_middle:: lint:: LintLevelSource ;
@@ -23,7 +23,7 @@ crate const CALCULATE_DOC_COVERAGE: Pass = Pass {
2323
2424fn calculate_doc_coverage ( krate : clean:: Crate , ctx : & mut DocContext < ' _ > ) -> clean:: Crate {
2525 let mut calc = CoverageCalculator { items : Default :: default ( ) , ctx } ;
26- let krate = calc. fold_crate ( krate) ;
26+ calc. visit_crate ( & krate) ;
2727
2828 calc. print_results ( ) ;
2929
@@ -182,17 +182,18 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {
182182 }
183183}
184184
185- impl < ' a , ' b > fold:: DocFolder for CoverageCalculator < ' a , ' b > {
186- fn fold_item ( & mut self , i : clean:: Item ) -> Option < clean:: Item > {
185+ impl < ' a , ' b > DocVisitor for CoverageCalculator < ' a , ' b > {
186+ fn visit_item ( & mut self , i : & clean:: Item ) {
187+ if !i. def_id . is_local ( ) {
188+ // non-local items are skipped because they can be out of the users control,
189+ // especially in the case of trait impls, which rustdoc eagerly inlines
190+ return ;
191+ }
192+
187193 match * i. kind {
188- _ if !i. def_id . is_local ( ) => {
189- // non-local items are skipped because they can be out of the users control,
190- // especially in the case of trait impls, which rustdoc eagerly inlines
191- return Some ( i) ;
192- }
193194 clean:: StrippedItem ( ..) => {
194195 // don't count items in stripped modules
195- return Some ( i ) ;
196+ return ;
196197 }
197198 // docs on `use` and `extern crate` statements are not displayed, so they're not
198199 // worth counting
@@ -269,6 +270,6 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
269270 }
270271 }
271272
272- Some ( self . fold_item_recur ( i ) )
273+ self . visit_item_recur ( i )
273274 }
274275}
0 commit comments