1
Fork 0

Rollup merge of #81227 - CraftSpider:struct-type-clean, r=jyn514

Remove doctree::StructType

Also removes it from the Union type, as unions can only ever be 'Plain'. Adds a new StructType to JSON, 'union', as the easiest way to encode the type of a union there. This leaves only one item in doctree, `Module`.

r? `@jyn514`
This commit is contained in:
Mara Bos 2021-01-22 14:30:16 +00:00 committed by GitHub
commit 2ceee72427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 53 deletions

View file

@ -5,11 +5,11 @@
use std::convert::From;
use rustc_ast::ast;
use rustc_hir::def::CtorKind;
use rustc_span::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_span::Pos;
use crate::clean;
use crate::doctree;
use crate::formats::item_type::ItemType;
use crate::json::types::*;
use crate::json::JsonRenderer;
@ -210,9 +210,9 @@ impl From<clean::Struct> for Struct {
impl From<clean::Union> for Struct {
fn from(struct_: clean::Union) -> Self {
let clean::Union { struct_type, generics, fields, fields_stripped } = struct_;
let clean::Union { generics, fields, fields_stripped } = struct_;
Struct {
struct_type: struct_type.into(),
struct_type: StructType::Union,
generics: generics.into(),
fields_stripped,
fields: ids(fields),
@ -221,13 +221,12 @@ impl From<clean::Union> for Struct {
}
}
impl From<doctree::StructType> for StructType {
fn from(struct_type: doctree::StructType) -> Self {
use doctree::StructType::*;
impl From<CtorKind> for StructType {
fn from(struct_type: CtorKind) -> Self {
match struct_type {
Plain => StructType::Plain,
Tuple => StructType::Tuple,
Unit => StructType::Unit,
CtorKind::Fictive => StructType::Plain,
CtorKind::Fn => StructType::Tuple,
CtorKind::Const => StructType::Unit,
}
}
}