]> git.lizzy.rs Git - rust.git/commitdiff
Update rustdoc coverage UI test
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 19 Aug 2020 20:44:58 +0000 (22:44 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 20 Aug 2020 15:42:17 +0000 (17:42 +0200)
src/librustdoc/passes/calculate_doc_coverage.rs
src/test/rustdoc-ui/coverage/json.rs
src/test/rustdoc-ui/coverage/json.stdout

index 1d79fc3f191f2b03ca8993d448466a90c267ba0c..08502c5b81731d3277bc9aae104ffb553a901d44 100644 (file)
@@ -249,7 +249,12 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
                 );
                 if should_have_doc_examples {
                     find_testable_code(
-                        &i.attrs.doc_strings.iter().map(|d| d.as_str()).collect::<Vec<_>>().join("\n"),
+                        &i.attrs
+                            .doc_strings
+                            .iter()
+                            .map(|d| d.as_str())
+                            .collect::<Vec<_>>()
+                            .join("\n"),
                         &mut tests,
                         ErrorCodes::No,
                         false,
@@ -259,10 +264,11 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
 
                 let has_doc_example = tests.found_tests != 0;
                 debug!("counting {:?} {:?} in {}", i.type_(), i.name, i.source.filename);
-                self.items
-                    .entry(i.source.filename.clone())
-                    .or_default()
-                    .count_item(has_docs, has_doc_example, should_have_doc_examples);
+                self.items.entry(i.source.filename.clone()).or_default().count_item(
+                    has_docs,
+                    has_doc_example,
+                    should_have_doc_examples,
+                );
             }
         }
 
index 2bd6a312ab58366207acc87b14237d58f23ffcba..a591cd5dba406ec1a0a29f72b163d9e6dab3eaae 100644 (file)
@@ -12,16 +12,54 @@ pub enum Bar { A }
 pub struct X;
 
 /// Bar
+///
+/// ```
+/// let x = 12;
+/// ```
 pub mod bar {
     /// bar
     pub struct Bar;
     /// X
-    pub enum X { Y }
+    pub enum X {
+        /// ```
+        /// let x = "should be ignored!";
+        /// ```
+        Y
+    }
 }
 
 /// yolo
+///
+/// ```text
+/// should not be counted as a code example!
+/// ```
 pub enum Yolo { X }
 
+impl Yolo {
+    /// ```
+    /// let x = "should be ignored!";
+    /// ```
+    pub const Const: u32 = 0;
+}
+
 pub struct Xo<T: Clone> {
+    /// ```
+    /// let x = "should be ignored!";
+    /// ```
     x: T,
 }
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub static StaticFoo: u32 = 0;
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub const ConstFoo: u32 = 0;
+
+/// ```
+/// let x = "should be ignored!";
+/// ```
+pub type TypeFoo = u32;
index 7b5b083e1584c01a1e6fde7688feec686921acb7..992f2751c8612e0cfc3f43ba27a50043a1dfa993 100644 (file)
@@ -1 +1 @@
-{"$DIR/json.rs":{"total":13,"with_docs":7,"with_examples":0}}
+{"$DIR/json.rs":{"total":17,"with_docs":12,"total_examples":10,"with_examples":1}}