about summary refs log tree commit diff
path: root/tests/rustdoc/private-fields-tuple-struct.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-09-08 08:23:02 +0200
committerGitHub <noreply@github.com>2023-09-08 08:23:02 +0200
commit403a18f13dd8f009c3ca31cea56d0c9dfea3c4d5 (patch)
treeba94dd46097ba682fe49df91e9abc38caaa60fcc /tests/rustdoc/private-fields-tuple-struct.rs
parent6b00cfbde7cdbd749e2ab8adb9aab2a17ecd99a7 (diff)
parentc4bb70f51b545d87a29bfb68898e5f4169345f8e (diff)
Rollup merge of #115604 - GuillaumeGomez:private-fields-tuple-struct, r=notriddle
rustdoc: Render private fields in tuple struct as `/* private fields */`

Reopening of https://github.com/rust-lang/rust/pull/110552. All that was missing was a test for the different cases so I added it into the second commit.

Description from the original PR:

> I've gotten some feedback that the current rustdoc rendering of...
>
> ```
> struct HasPrivateFields(_);
> ```
>
> ...is confusing, and I agree with that feedback, especially compared to the field struct case:
>
> ```
> struct HasPrivateFields { /* private fields */ }
> ```
>
> So this PR makes it so that when all of the fields of a tuple variant are private, just render it with the `/* private fields */` comment. We can't *always* render it like that, for example when there's a mix of private and public fields.

cc ````@jsha````
r? ````@notriddle````
Diffstat (limited to 'tests/rustdoc/private-fields-tuple-struct.rs')
-rw-r--r--tests/rustdoc/private-fields-tuple-struct.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/rustdoc/private-fields-tuple-struct.rs b/tests/rustdoc/private-fields-tuple-struct.rs
new file mode 100644
index 00000000000..c6989dd8cdf
--- /dev/null
+++ b/tests/rustdoc/private-fields-tuple-struct.rs
@@ -0,0 +1,15 @@
+// This test checks the diplay of "/* private fields */" sentence in tuple structs.
+#![crate_name = "foo"]
+
+// @has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);'
+pub struct A(pub u8, u8);
+// @has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);'
+pub struct B(u8, pub u8);
+// @has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);'
+pub struct C(u8, pub u8, u8);
+// @has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);'
+pub struct D(pub u8, u8, pub u8);
+// @has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);'
+pub struct E(u8);
+// @has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);'
+pub struct F(u8, u8);