Auto merge of #118192 - Kyuuhachi:issue-118180, r=fmease
Don't print "private fields" on empty tuple structs Closes #118180. While working on this I also noticed that empty struct variants are also rendered rather awkwardly. I'll make another issue for that, since I don't know what the correct rendering would be.
This commit is contained in:
commit
a4a5c976fe
@ -1501,8 +1501,10 @@ fn print_tuple_struct_fields<'a, 'cx: 'a>(
|
|||||||
s: &'a [clean::Item],
|
s: &'a [clean::Item],
|
||||||
) -> impl fmt::Display + 'a + Captures<'cx> {
|
) -> impl fmt::Display + 'a + Captures<'cx> {
|
||||||
display_fn(|f| {
|
display_fn(|f| {
|
||||||
if s.iter()
|
if !s.is_empty()
|
||||||
.all(|field| matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..))))
|
&& s.iter().all(|field| {
|
||||||
|
matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
|
||||||
|
})
|
||||||
{
|
{
|
||||||
return f.write_str("/* private fields */");
|
return f.write_str("/* private fields */");
|
||||||
}
|
}
|
||||||
@ -2275,9 +2277,11 @@ fn render_struct_fields(
|
|||||||
}
|
}
|
||||||
Some(CtorKind::Fn) => {
|
Some(CtorKind::Fn) => {
|
||||||
w.write_str("(");
|
w.write_str("(");
|
||||||
if fields.iter().all(|field| {
|
if !fields.is_empty()
|
||||||
matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
|
&& fields.iter().all(|field| {
|
||||||
}) {
|
matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
|
||||||
|
})
|
||||||
|
{
|
||||||
write!(w, "/* private fields */");
|
write!(w, "/* private fields */");
|
||||||
} else {
|
} else {
|
||||||
for (i, field) in fields.iter().enumerate() {
|
for (i, field) in fields.iter().enumerate() {
|
||||||
|
9
tests/rustdoc/issue-118180-empty-tuple-struct.rs
Normal file
9
tests/rustdoc/issue-118180-empty-tuple-struct.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// @has issue_118180_empty_tuple_struct/enum.Enum.html
|
||||||
|
pub enum Enum {
|
||||||
|
// @has - '//*[@id="variant.Empty"]//h3' 'Empty()'
|
||||||
|
Empty(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has issue_118180_empty_tuple_struct/struct.Empty.html
|
||||||
|
// @has - '//pre/code' 'Empty()'
|
||||||
|
pub struct Empty();
|
Loading…
x
Reference in New Issue
Block a user