Move StructType to clean, remove it from Unions, make JSON output whether something is a union

This commit is contained in:
Rune Tynan
2021-01-20 16:46:34 -05:00
parent a4cbb44ae2
commit 450c5eae1d
7 changed files with 40 additions and 47 deletions

View File

@@ -68,7 +68,6 @@ use serde::{Serialize, Serializer};
use crate::clean::{self, AttributesExt, GetDefId, RenderedLink, SelfTy, TypeKind};
use crate::config::{RenderInfo, RenderOptions};
use crate::docfs::{DocFS, PathError};
use crate::doctree;
use crate::error::Error;
use crate::formats::cache::{cache, Cache};
use crate::formats::item_type::ItemType;
@@ -3101,7 +3100,7 @@ fn item_struct(
_ => None,
})
.peekable();
if let doctree::Plain = s.struct_type {
if let clean::StructType::Plain = s.struct_type {
if fields.peek().is_some() {
write!(
w,
@@ -3351,7 +3350,7 @@ fn render_struct(
w: &mut Buffer,
it: &clean::Item,
g: Option<&clean::Generics>,
ty: doctree::StructType,
ty: clean::StructType,
fields: &[clean::Item],
tab: &str,
structhead: bool,
@@ -3368,7 +3367,7 @@ fn render_struct(
write!(w, "{}", g.print())
}
match ty {
doctree::Plain => {
clean::StructType::Plain => {
if let Some(g) = g {
write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: true })
}
@@ -3400,7 +3399,7 @@ fn render_struct(
}
write!(w, "}}");
}
doctree::Tuple => {
clean::StructType::Tuple => {
write!(w, "(");
for (i, field) in fields.iter().enumerate() {
if i > 0 {
@@ -3425,7 +3424,7 @@ fn render_struct(
}
write!(w, ";");
}
doctree::Unit => {
clean::StructType::Unit => {
// Needed for PhantomData.
if let Some(g) = g {
write!(w, "{}", WhereClause { gens: g, indent: 0, end_newline: false })
@@ -4460,7 +4459,7 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
let fields = get_struct_fields_name(&s.fields);
if !fields.is_empty() {
if let doctree::Plain = s.struct_type {
if let clean::StructType::Plain = s.struct_type {
sidebar.push_str(&format!(
"<a class=\"sidebar-title\" href=\"#fields\">Fields</a>\
<div class=\"sidebar-links\">{}</div>",