]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/passes/calculate_doc_coverage.rs
Update how doc examples are counted
[rust.git] / src / librustdoc / passes / calculate_doc_coverage.rs
index 93a271b81fb512d5dafb675293cf74dcba5c70e5..1bdd337dabecb4feb9ddacac2d2fb6e893bb8580 100644 (file)
@@ -47,11 +47,11 @@ fn count_item(
         if has_docs {
             self.with_docs += 1;
         }
-        if should_have_doc_examples {
+        if should_have_doc_examples || has_doc_example {
+            self.total_examples += 1;
+        }
+        if has_doc_example {
             self.with_examples += 1;
-            if has_doc_example {
-                self.with_examples += 1;
-            }
         }
     }
 
@@ -246,20 +246,18 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
                     | clean::StaticItem(_)
                     | clean::ConstantItem(_)
                 );
-                if should_have_doc_examples {
-                    find_testable_code(
-                        &i.attrs
-                            .doc_strings
-                            .iter()
-                            .map(|d| d.as_str())
-                            .collect::<Vec<_>>()
-                            .join("\n"),
-                        &mut tests,
-                        ErrorCodes::No,
-                        false,
-                        None,
-                    );
-                }
+                find_testable_code(
+                    &i.attrs
+                        .doc_strings
+                        .iter()
+                        .map(|d| d.as_str())
+                        .collect::<Vec<_>>()
+                        .join("\n"),
+                    &mut tests,
+                    ErrorCodes::No,
+                    false,
+                    None,
+                );
 
                 let has_doc_example = tests.found_tests != 0;
                 debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);