Skip to content

Commit b24b0fd

Browse files
authored
Rollup merge of #92699 - camelid:private-fields, r=jsha
rustdoc: Display "private fields" instead of "fields omitted" Also: * Always use `/* */` block comments * Use the same message everywhere, rather than sometimes prefixing with "some" When I first read rustdoc docs, I was confused why the fields were being omitted. It was only later that I realized it was because they were private. It's also always bothered me that rustdoc sometimes uses `//` and sometimes uses `/*` comments for these messages, so this change makes them all use `/*`. Technically, I think fields can be omitted if they are public but `doc(hidden)` too, but `doc(hidden)` is analogous to privacy. It's really just used to emulate "doc privacy" when -- because of technical limitations -- an item has to be public. So I think it's fine to include this under the category of "private fields". r? ```@jsha```
2 parents 9ea9e18 + 2b70a3d commit b24b0fd

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

Diff for: src/librustdoc/html/render/print_item.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ fn render_union(
15571557
}
15581558

15591559
if it.has_stripped_fields().unwrap() {
1560-
write!(w, " // some fields omitted\n{}", tab);
1560+
write!(w, " /* private fields */\n{}", tab);
15611561
}
15621562
if toggle {
15631563
toggle_close(w);
@@ -1613,13 +1613,11 @@ fn render_struct(
16131613

16141614
if has_visible_fields {
16151615
if it.has_stripped_fields().unwrap() {
1616-
write!(w, "\n{} // some fields omitted", tab);
1616+
write!(w, "\n{} /* private fields */", tab);
16171617
}
16181618
write!(w, "\n{}", tab);
16191619
} else if it.has_stripped_fields().unwrap() {
1620-
// If there are no visible fields we can just display
1621-
// `{ /* fields omitted */ }` to save space.
1622-
write!(w, " /* fields omitted */ ");
1620+
write!(w, " /* private fields */ ");
16231621
}
16241622
if toggle {
16251623
toggle_close(w);

Diff for: src/test/rustdoc/structfields.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub struct Foo {
33
// @has - //pre "pub a: ()"
44
pub a: (),
5-
// @has - //pre "// some fields omitted"
5+
// @has - //pre "/* private fields */"
66
// @!has - //pre "b: ()"
77
b: (),
88
// @!has - //pre "c: usize"
@@ -16,7 +16,7 @@ pub struct Foo {
1616
pub struct Bar {
1717
// @has - //pre "pub a: ()"
1818
pub a: (),
19-
// @!has - //pre "// some fields omitted"
19+
// @!has - //pre "/* private fields */"
2020
}
2121

2222
// @has structfields/enum.Qux.html
@@ -29,11 +29,11 @@ pub enum Qux {
2929
b: (),
3030
// @has - //pre "c: usize"
3131
c: usize,
32-
// @has - //pre "// some fields omitted"
32+
// @has - //pre "/* private fields */"
3333
},
3434
}
3535

36-
// @has structfields/struct.Baz.html //pre "pub struct Baz { /* fields omitted */ }"
36+
// @has structfields/struct.Baz.html //pre "pub struct Baz { /* private fields */ }"
3737
pub struct Baz {
3838
x: u8,
3939
#[doc(hidden)]

Diff for: src/test/rustdoc/toggle-item-contents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub union Union {
5555

5656
// @has 'toggle_item_contents/struct.PrivStruct.html'
5757
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0
58-
// @has - '//div[@class="docblock item-decl"]' 'fields omitted'
58+
// @has - '//div[@class="docblock item-decl"]' '/* private fields */'
5959
pub struct PrivStruct {
6060
a: usize,
6161
b: usize,

Diff for: src/test/rustdoc/union.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub union U {
33
// @has - //pre "pub a: u8"
44
pub a: u8,
5-
// @has - //pre "// some fields omitted"
5+
// @has - //pre "/* private fields */"
66
// @!has - //pre "b: u16"
77
b: u16,
88
}

0 commit comments

Comments
 (0)