about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-03 20:54:56 +0000
committerbors <bors@rust-lang.org>2023-12-03 20:54:56 +0000
commit9fad6859925b34f9a0b1af592a7839ccb1e71f60 (patch)
treecc78ca752f81a81c7f270a2e7891521f43760b43
parentd12dc74a2c2543619fc38c98b2efe6f76d552196 (diff)
parentcaeaf313165b678b1a1c46f5565ef34391b46d8b (diff)
downloadrust-9fad6859925b34f9a0b1af592a7839ccb1e71f60.tar.gz
rust-9fad6859925b34f9a0b1af592a7839ccb1e71f60.zip
Auto merge of #118579 - matthiaskrgr:rollup-22kn8sa, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #117869 ([rustdoc] Add highlighting for comments in items declaration)
 - #118525 (coverage: Skip spans that can't be un-expanded back to the function body)
 - #118574 (rustc_session: Address all `rustc::potential_query_instability` lints)

r? `@ghost`
`@rustbot` modify labels: rollup
-rw-r--r--compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs12
-rw-r--r--compiler/rustc_session/src/code_stats.rs4
-rw-r--r--compiler/rustc_session/src/lib.rs1
-rw-r--r--compiler/rustc_session/src/parse.rs3
-rw-r--r--src/librustdoc/html/render/print_item.rs22
-rw-r--r--tests/coverage/async.cov-map12
-rw-r--r--tests/coverage/async2.cov-map12
-rw-r--r--tests/coverage/inline.cov-map4
-rw-r--r--tests/coverage/inline.coverage2
-rw-r--r--tests/coverage/unreachable.cov-map12
-rw-r--r--tests/coverage/unreachable.coverage4
-rw-r--r--tests/rustdoc-gui/item-decl-comment-highlighting.goml73
-rw-r--r--tests/rustdoc-gui/sidebar-source-code.goml2
-rw-r--r--tests/rustdoc-gui/src/proc_macro_test/Cargo.lock7
-rw-r--r--tests/rustdoc-gui/src/proc_macro_test/Cargo.toml8
-rw-r--r--tests/rustdoc-gui/src/proc_macro_test/lib.rs11
-rw-r--r--tests/rustdoc-gui/src/test_docs/lib.rs18
-rw-r--r--tests/rustdoc/where.SWhere_Simd_item-decl.html4
-rw-r--r--tests/rustdoc/where.alpha_trait_decl.html2
-rw-r--r--tests/rustdoc/whitespace-after-where-clause.union.html2
-rw-r--r--tests/rustdoc/whitespace-after-where-clause.union2.html2
21 files changed, 174 insertions, 43 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs
index 6189e5379ea..e1531f2c239 100644
--- a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs
+++ b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs
@@ -63,14 +63,14 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>(
 
         let statement_spans = data.statements.iter().filter_map(move |statement| {
             let expn_span = filtered_statement_span(statement)?;
-            let span = function_source_span(expn_span, body_span);
+            let span = unexpand_into_body_span(expn_span, body_span)?;
 
             Some(CoverageSpan::new(span, expn_span, bcb, is_closure(statement)))
         });
 
         let terminator_span = Some(data.terminator()).into_iter().filter_map(move |terminator| {
             let expn_span = filtered_terminator_span(terminator)?;
-            let span = function_source_span(expn_span, body_span);
+            let span = unexpand_into_body_span(expn_span, body_span)?;
 
             Some(CoverageSpan::new(span, expn_span, bcb, false))
         });
@@ -180,14 +180,16 @@ fn filtered_terminator_span(terminator: &Terminator<'_>) -> Option<Span> {
 /// Returns an extrapolated span (pre-expansion[^1]) corresponding to a range
 /// within the function's body source. This span is guaranteed to be contained
 /// within, or equal to, the `body_span`. If the extrapolated span is not
-/// contained within the `body_span`, the `body_span` is returned.
+/// contained within the `body_span`, `None` is returned.
 ///
 /// [^1]Expansions result from Rust syntax including macros, syntactic sugar,
 /// etc.).
 #[inline]
-fn function_source_span(span: Span, body_span: Span) -> Span {
+fn unexpand_into_body_span(span: Span, body_span: Span) -> Option<Span> {
     use rustc_span::source_map::original_sp;
 
+    // FIXME(#118525): Consider switching from `original_sp` to `Span::find_ancestor_inside`,
+    // which is similar but gives slightly different results in some edge cases.
     let original_span = original_sp(span, body_span).with_ctxt(body_span.ctxt());
-    if body_span.contains(original_span) { original_span } else { body_span }
+    body_span.contains(original_span).then_some(original_span)
 }
diff --git a/compiler/rustc_session/src/code_stats.rs b/compiler/rustc_session/src/code_stats.rs
index e1eb58fecc7..2553df33cc7 100644
--- a/compiler/rustc_session/src/code_stats.rs
+++ b/compiler/rustc_session/src/code_stats.rs
@@ -132,6 +132,8 @@ impl CodeStats {
 
     pub fn print_type_sizes(&self) {
         let type_sizes = self.type_sizes.borrow();
+        // We will soon sort, so the initial order does not matter.
+        #[allow(rustc::potential_query_instability)]
         let mut sorted: Vec<_> = type_sizes.iter().collect();
 
         // Primary sort: large-to-small.
@@ -227,6 +229,8 @@ impl CodeStats {
     }
 
     pub fn print_vtable_sizes(&self, crate_name: Symbol) {
+        // We will soon sort, so the initial order does not matter.
+        #[allow(rustc::potential_query_instability)]
         let mut infos =
             std::mem::take(&mut *self.vtable_sizes.lock()).into_values().collect::<Vec<_>>();
 
diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs
index 0b55af2f73b..805854bd5cf 100644
--- a/compiler/rustc_session/src/lib.rs
+++ b/compiler/rustc_session/src/lib.rs
@@ -6,7 +6,6 @@
 #![feature(map_many_mut)]
 #![feature(iter_intersperse)]
 #![recursion_limit = "256"]
-#![allow(rustc::potential_query_instability)]
 #![deny(rustc::untranslatable_diagnostic)]
 #![deny(rustc::diagnostic_outside_of_impl)]
 #![allow(internal_features)]
diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs
index f7b33cb598b..881e1de6755 100644
--- a/compiler/rustc_session/src/parse.rs
+++ b/compiler/rustc_session/src/parse.rs
@@ -51,6 +51,9 @@ impl GatedSpans {
     /// Prepend the given set of `spans` onto the set in `self`.
     pub fn merge(&self, mut spans: FxHashMap<Symbol, Vec<Span>>) {
         let mut inner = self.spans.borrow_mut();
+        // The entries will be moved to another map so the drain order does not
+        // matter.
+        #[allow(rustc::potential_query_instability)]
         for (gate, mut gate_spans) in inner.drain() {
             spans.entry(gate).or_default().append(&mut gate_spans);
         }
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index e4309c782f6..131b1d608e6 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1509,7 +1509,7 @@ fn print_tuple_struct_fields<'a, 'cx: 'a>(
                 matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
             })
         {
-            return f.write_str("/* private fields */");
+            return f.write_str("<span class=\"comment\">/* private fields */</span>");
         }
 
         for (i, ty) in s.iter().enumerate() {
@@ -1666,7 +1666,7 @@ fn render_enum_fields(
         }
 
         if variants_stripped && !is_non_exhaustive {
-            w.write_str("    // some variants omitted\n");
+            w.write_str("    <span class=\"comment\">// some variants omitted</span>\n");
         }
         if toggle {
             toggle_close(&mut w);
@@ -1811,7 +1811,8 @@ fn item_proc_macro(
         let name = it.name.expect("proc-macros always have names");
         match m.kind {
             MacroKind::Bang => {
-                write!(buffer, "{name}!() {{ /* proc-macro */ }}").unwrap();
+                write!(buffer, "{name}!() {{ <span class=\"comment\">/* proc-macro */</span> }}")
+                    .unwrap();
             }
             MacroKind::Attr => {
                 write!(buffer, "#[{name}]").unwrap();
@@ -1819,7 +1820,12 @@ fn item_proc_macro(
             MacroKind::Derive => {
                 write!(buffer, "#[derive({name})]").unwrap();
                 if !m.helpers.is_empty() {
-                    buffer.write_str("\n{\n    // Attributes available to this derive:\n").unwrap();
+                    buffer
+                        .write_str(
+                            "\n{\n    \
+                        <span class=\"comment\">// Attributes available to this derive:</span>\n",
+                        )
+                        .unwrap();
                     for attr in &m.helpers {
                         writeln!(buffer, "    #[{attr}]").unwrap();
                     }
@@ -2181,7 +2187,7 @@ fn render_union<'a, 'cx: 'a>(
         }
 
         if it.has_stripped_entries().unwrap() {
-            write!(f, "    /* private fields */\n")?;
+            write!(f, "    <span class=\"comment\">/* private fields */</span>\n")?;
         }
         if toggle {
             toggle_close(&mut f);
@@ -2267,11 +2273,11 @@ fn render_struct_fields(
 
             if has_visible_fields {
                 if has_stripped_entries {
-                    write!(w, "\n{tab}    /* private fields */");
+                    write!(w, "\n{tab}    <span class=\"comment\">/* private fields */</span>");
                 }
                 write!(w, "\n{tab}");
             } else if has_stripped_entries {
-                write!(w, " /* private fields */ ");
+                write!(w, " <span class=\"comment\">/* private fields */</span> ");
             }
             if toggle {
                 toggle_close(&mut w);
@@ -2285,7 +2291,7 @@ fn render_struct_fields(
                     matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
                 })
             {
-                write!(w, "/* private fields */");
+                write!(w, "<span class=\"comment\">/* private fields */</span>");
             } else {
                 for (i, field) in fields.iter().enumerate() {
                     if i > 0 {
diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map
index 857e0a536a7..e4354a1af87 100644
--- a/tests/coverage/async.cov-map
+++ b/tests/coverage/async.cov-map
@@ -74,28 +74,28 @@ Number of file 0 mappings: 6
     = ((c0 + c1) - c1)
 
 Function name: async::executor::block_on::VTABLE::{closure#0}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 49)
 
 Function name: async::executor::block_on::VTABLE::{closure#1}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 49)
 
 Function name: async::executor::block_on::VTABLE::{closure#2}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 49)
 
 Function name: async::executor::block_on::VTABLE::{closure#3}
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 75, 11, 00, 13]
diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map
index cc7aed9aee3..23f26ee4e5f 100644
--- a/tests/coverage/async2.cov-map
+++ b/tests/coverage/async2.cov-map
@@ -78,28 +78,28 @@ Number of file 0 mappings: 6
     = ((c0 + c1) - c1)
 
 Function name: async2::executor::block_on::VTABLE::{closure#0}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 49)
 
 Function name: async2::executor::block_on::VTABLE::{closure#1}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 49)
 
 Function name: async2::executor::block_on::VTABLE::{closure#2}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 33]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 31]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 51)
+- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 49)
 
 Function name: async2::executor::block_on::VTABLE::{closure#3}
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 2e, 11, 00, 13]
diff --git a/tests/coverage/inline.cov-map b/tests/coverage/inline.cov-map
index 72b10fd0cc2..001c333ae6d 100644
--- a/tests/coverage/inline.cov-map
+++ b/tests/coverage/inline.cov-map
@@ -15,12 +15,12 @@ Number of file 0 mappings: 5
     = ((c0 + c1) - c1)
 
 Function name: inline::error
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 02, 02]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 01, 14]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 49, 1) to (start + 2, 2)
+- Code(Counter(0)) at (prev + 49, 1) to (start + 1, 20)
 
 Function name: inline::length::<char>
 Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02]
diff --git a/tests/coverage/inline.coverage b/tests/coverage/inline.coverage
index 6efd9a0830b..68a2e408306 100644
--- a/tests/coverage/inline.coverage
+++ b/tests/coverage/inline.coverage
@@ -50,5 +50,5 @@
    LL|       |#[inline(always)]
    LL|      0|fn error() {
    LL|      0|    panic!("error");
-   LL|      0|}
+   LL|       |}
 
diff --git a/tests/coverage/unreachable.cov-map b/tests/coverage/unreachable.cov-map
index 495419820c1..55d124a16f5 100644
--- a/tests/coverage/unreachable.cov-map
+++ b/tests/coverage/unreachable.cov-map
@@ -1,24 +1,24 @@
 Function name: unreachable::UNREACHABLE_CLOSURE::{closure#0}
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 27, 00, 49]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 27, 00, 47]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 15, 39) to (start + 0, 73)
+- Code(Counter(0)) at (prev + 15, 39) to (start + 0, 71)
 
 Function name: unreachable::unreachable_function
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 02, 02]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 01, 25]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 17, 1) to (start + 2, 2)
+- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 37)
 
 Function name: unreachable::unreachable_intrinsic
-Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 02, 02]
+Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 01, 2c]
 Number of files: 1
 - file 0 => global file 1
 Number of expressions: 0
 Number of file 0 mappings: 1
-- Code(Counter(0)) at (prev + 22, 1) to (start + 2, 2)
+- Code(Counter(0)) at (prev + 22, 1) to (start + 1, 44)
 
diff --git a/tests/coverage/unreachable.coverage b/tests/coverage/unreachable.coverage
index fa0ac9ccfa1..7015bb90aa3 100644
--- a/tests/coverage/unreachable.coverage
+++ b/tests/coverage/unreachable.coverage
@@ -16,12 +16,12 @@
    LL|       |
    LL|      0|fn unreachable_function() {
    LL|      0|    unsafe { unreachable_unchecked() }
-   LL|      0|}
+   LL|       |}
    LL|       |
    LL|       |// Use an intrinsic to more reliably trigger unreachable-propagation.
    LL|      0|fn unreachable_intrinsic() {
    LL|      0|    unsafe { std::intrinsics::unreachable() }
-   LL|      0|}
+   LL|       |}
    LL|       |
    LL|       |#[coverage(off)]
    LL|       |fn main() {
diff --git a/tests/rustdoc-gui/item-decl-comment-highlighting.goml b/tests/rustdoc-gui/item-decl-comment-highlighting.goml
new file mode 100644
index 00000000000..60772693d6c
--- /dev/null
+++ b/tests/rustdoc-gui/item-decl-comment-highlighting.goml
@@ -0,0 +1,73 @@
+// This test checks that comments in item declarations are highlighted.
+go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
+show-text: true
+
+define-function: (
+    "check-item-decl-comment",
+    (theme, url, comment_color),
+    block {
+        go-to: |url|
+        set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
+        reload:
+        assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
+    }
+)
+
+define-function: (
+    "check-items-for-theme",
+    (theme, comment_color),
+    block {
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html",
+            "comment_color": |comment_color|,
+        })
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Struct.html",
+            "comment_color": |comment_color|,
+        })
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Tuple.html",
+            "comment_color": |comment_color|,
+        })
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/test_docs/private/union.Union.html",
+            "comment_color": |comment_color|,
+        })
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/proc_macro_test/macro.make_answer.html",
+            "comment_color": |comment_color|,
+        })
+        call-function: ("check-item-decl-comment", {
+            "theme": |theme|,
+            "url": "file://" + |DOC_PATH| + "/proc_macro_test/derive.HelperAttr.html",
+            "comment_color": |comment_color|,
+        })
+    }
+)
+
+call-function: (
+    "check-items-for-theme",
+    {
+        "theme": "ayu",
+        "comment_color": "#788797",
+    }
+)
+call-function: (
+    "check-items-for-theme",
+    {
+        "theme": "dark",
+        "comment_color": "#8d8d8b",
+    }
+)
+call-function: (
+    "check-items-for-theme",
+    {
+        "theme": "light",
+        "comment_color": "#8e908c",
+    }
+)
diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml
index 92b9045b734..0d72e670cf4 100644
--- a/tests/rustdoc-gui/sidebar-source-code.goml
+++ b/tests/rustdoc-gui/sidebar-source-code.goml
@@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
 // Only "another_folder" should be "open" in "lib2".
 assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
 // All other trees should be collapsed.
-assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 10)
+assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 11)
 
 // We now switch to mobile mode.
 set-window-size: (600, 600)
diff --git a/tests/rustdoc-gui/src/proc_macro_test/Cargo.lock b/tests/rustdoc-gui/src/proc_macro_test/Cargo.lock
new file mode 100644
index 00000000000..eae9d75367f
--- /dev/null
+++ b/tests/rustdoc-gui/src/proc_macro_test/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "proc_macro_test"
+version = "0.1.0"
diff --git a/tests/rustdoc-gui/src/proc_macro_test/Cargo.toml b/tests/rustdoc-gui/src/proc_macro_test/Cargo.toml
new file mode 100644
index 00000000000..768ced65184
--- /dev/null
+++ b/tests/rustdoc-gui/src/proc_macro_test/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "proc_macro_test"
+version = "0.1.0"
+edition = "2021"
+
+[lib]
+path = "lib.rs"
+proc-macro = true
diff --git a/tests/rustdoc-gui/src/proc_macro_test/lib.rs b/tests/rustdoc-gui/src/proc_macro_test/lib.rs
new file mode 100644
index 00000000000..8a6c62df87c
--- /dev/null
+++ b/tests/rustdoc-gui/src/proc_macro_test/lib.rs
@@ -0,0 +1,11 @@
+use proc_macro::TokenStream;
+
+#[proc_macro]
+pub fn make_answer(_item: TokenStream) -> TokenStream {
+    "fn answer() -> u32 { 42 }".parse().unwrap()
+}
+
+#[proc_macro_derive(HelperAttr, attributes(helper))]
+pub fn derive_helper_attr(_item: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index c7d115bdb98..0bc777230bf 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -593,3 +593,21 @@ pub mod foreign_impl_order {
         fn f(&mut self, fg: [u8; 3]) {}
     }
 }
+
+pub mod private {
+    pub struct Tuple(u32, u8);
+    pub struct Struct {
+        a: u8,
+    }
+
+    pub union Union {
+        a: u8,
+        b: u16,
+    }
+
+    pub enum Enum {
+        A,
+        #[doc(hidden)]
+        B,
+    }
+}
diff --git a/tests/rustdoc/where.SWhere_Simd_item-decl.html b/tests/rustdoc/where.SWhere_Simd_item-decl.html
index 46708b9e4e9..1987b1d59f5 100644
--- a/tests/rustdoc/where.SWhere_Simd_item-decl.html
+++ b/tests/rustdoc/where.SWhere_Simd_item-decl.html
@@ -1,3 +1,3 @@
-<pre class="rust item-decl"><code>pub struct Simd&lt;T&gt;(/* private fields */)
+<pre class="rust item-decl"><code>pub struct Simd&lt;T&gt;(<span class="comment">/* private fields */</span>)
 <span class="where">where
-    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre>
+    T: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code></pre>
\ No newline at end of file
diff --git a/tests/rustdoc/where.alpha_trait_decl.html b/tests/rustdoc/where.alpha_trait_decl.html
index 0c0b2d1ceca..2c010ca7c2d 100644
--- a/tests/rustdoc/where.alpha_trait_decl.html
+++ b/tests/rustdoc/where.alpha_trait_decl.html
@@ -1,3 +1,3 @@
-<code>pub struct Alpha&lt;A&gt;(/* private fields */)
+<code>pub struct Alpha&lt;A&gt;(<span class="comment">/* private fields */</span>)
 <span class="where">where
     A: <a class="trait" href="trait.MyTrait.html" title="trait foo::MyTrait">MyTrait</a></span>;</code>
\ No newline at end of file
diff --git a/tests/rustdoc/whitespace-after-where-clause.union.html b/tests/rustdoc/whitespace-after-where-clause.union.html
index 7e0d5f8717a..e63374760d9 100644
--- a/tests/rustdoc/whitespace-after-where-clause.union.html
+++ b/tests/rustdoc/whitespace-after-where-clause.union.html
@@ -1,4 +1,4 @@
 <pre class="rust item-decl"><code>pub union Union&lt;'a, B&gt;<div class="where">where
     B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</div>{
-    /* private fields */
+    <span class="comment">/* private fields */</span>
 }</code></pre>
\ No newline at end of file
diff --git a/tests/rustdoc/whitespace-after-where-clause.union2.html b/tests/rustdoc/whitespace-after-where-clause.union2.html
index 177a161b83a..da984343daa 100644
--- a/tests/rustdoc/whitespace-after-where-clause.union2.html
+++ b/tests/rustdoc/whitespace-after-where-clause.union2.html
@@ -1,3 +1,3 @@
 <pre class="rust item-decl"><code>pub union Union2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + 'a&gt; {
-    /* private fields */
+    <span class="comment">/* private fields */</span>
 }</code></pre>
\ No newline at end of file