1
1
use crate :: clean;
2
2
use crate :: core:: DocContext ;
3
- use crate :: fold:: { self , DocFolder } ;
4
3
use crate :: html:: markdown:: { find_testable_code, ErrorCodes } ;
5
4
use crate :: passes:: check_doc_test_visibility:: { should_have_doc_example, Tests } ;
6
5
use crate :: passes:: Pass ;
6
+ use crate :: visit:: DocVisitor ;
7
7
use rustc_hir as hir;
8
8
use rustc_lint:: builtin:: MISSING_DOCS ;
9
9
use rustc_middle:: lint:: LintLevelSource ;
@@ -23,7 +23,7 @@ crate const CALCULATE_DOC_COVERAGE: Pass = Pass {
23
23
24
24
fn calculate_doc_coverage ( krate : clean:: Crate , ctx : & mut DocContext < ' _ > ) -> clean:: Crate {
25
25
let mut calc = CoverageCalculator { items : Default :: default ( ) , ctx } ;
26
- let krate = calc. fold_crate ( krate) ;
26
+ calc. visit_crate ( & krate) ;
27
27
28
28
calc. print_results ( ) ;
29
29
@@ -182,17 +182,18 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {
182
182
}
183
183
}
184
184
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
+
187
193
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
- }
193
194
clean:: StrippedItem ( ..) => {
194
195
// don't count items in stripped modules
195
- return Some ( i ) ;
196
+ return ;
196
197
}
197
198
// docs on `use` and `extern crate` statements are not displayed, so they're not
198
199
// worth counting
@@ -269,6 +270,6 @@ impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
269
270
}
270
271
}
271
272
272
- Some ( self . fold_item_recur ( i ) )
273
+ self . visit_item_recur ( i )
273
274
}
274
275
}
0 commit comments