about summary refs log tree commit diff
path: root/src/librustdoc/json
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-01-22 14:30:16 +0000
committerGitHub <noreply@github.com>2021-01-22 14:30:16 +0000
commit2ceee724270f2186e5e85acff49acd35bf8a652a (patch)
treebfa6e0acd7028f38e9327aa3b8d037b308d2b41f /src/librustdoc/json
parent1cc13b4f5a576e4517813ca47de316271f1e26b3 (diff)
parent3349b40d471bea1e1b154213b19fbeb5a965943c (diff)
downloadrust-2ceee724270f2186e5e85acff49acd35bf8a652a.tar.gz
rust-2ceee724270f2186e5e85acff49acd35bf8a652a.zip
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`
Diffstat (limited to 'src/librustdoc/json')
-rw-r--r--src/librustdoc/json/conversions.rs17
-rw-r--r--src/librustdoc/json/types.rs1
2 files changed, 9 insertions, 9 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs
index d8f1f515796..bfd2141d9a1 100644
--- a/src/librustdoc/json/conversions.rs
+++ b/src/librustdoc/json/conversions.rs
@@ -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,
         }
     }
 }
diff --git a/src/librustdoc/json/types.rs b/src/librustdoc/json/types.rs
index c148602009f..66cf12954dd 100644
--- a/src/librustdoc/json/types.rs
+++ b/src/librustdoc/json/types.rs
@@ -270,6 +270,7 @@ pub enum StructType {
     Plain,
     Tuple,
     Unit,
+    Union,
 }
 
 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]