From 435b90970f0028975440c1e32a6a9b99fd8b6ea4 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 22 Jan 2021 16:09:24 -0500 Subject: [PATCH 1/7] Split JSON into separately versioned crate --- Cargo.toml | 1 + src/librustdoc/Cargo.toml | 1 + src/librustdoc/json-types/Cargo.toml | 11 +++ .../{json/types.rs => json-types/lib.rs} | 10 +-- src/librustdoc/json/conversions.rs | 83 +++++++++---------- src/librustdoc/json/mod.rs | 25 ++++-- 6 files changed, 72 insertions(+), 59 deletions(-) create mode 100644 src/librustdoc/json-types/Cargo.toml rename src/librustdoc/{json/types.rs => json-types/lib.rs} (98%) diff --git a/Cargo.toml b/Cargo.toml index 5bd1147cad554..5b58ed8f6a050 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "compiler/rustc", "library/std", "library/test", + "src/librustdoc/json-types", "src/tools/cargotest", "src/tools/clippy", "src/tools/compiletest", diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index b0f5bac6abd0f..bc6eba74d2d48 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -17,6 +17,7 @@ smallvec = "1.0" tempfile = "3" itertools = "0.9" regex = "1" +json-types = { path = "./json-types" } [dev-dependencies] expect-test = "1.0" diff --git a/src/librustdoc/json-types/Cargo.toml b/src/librustdoc/json-types/Cargo.toml new file mode 100644 index 0000000000000..b9c97c31c1877 --- /dev/null +++ b/src/librustdoc/json-types/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "json-types" +version = "0.1.0" +authors = ["The Rust Project Developers"] +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } diff --git a/src/librustdoc/json/types.rs b/src/librustdoc/json-types/lib.rs similarity index 98% rename from src/librustdoc/json/types.rs rename to src/librustdoc/json-types/lib.rs index 66cf12954dd0b..3fb2a32d5a0a3 100644 --- a/src/librustdoc/json/types.rs +++ b/src/librustdoc/json-types/lib.rs @@ -3,9 +3,9 @@ //! These types are the public API exposed through the `--output-format json` flag. The [`Crate`] //! struct is the root of the JSON blob and all other items are contained within. +use std::collections::HashMap; use std::path::PathBuf; -use rustc_data_structures::fx::FxHashMap; use serde::{Deserialize, Serialize}; /// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information @@ -21,11 +21,11 @@ pub struct Crate { pub includes_private: bool, /// A collection of all items in the local crate as well as some external traits and their /// items that are referenced locally. - pub index: FxHashMap, + pub index: HashMap, /// Maps IDs to fully qualified paths and other info helpful for generating links. - pub paths: FxHashMap, + pub paths: HashMap, /// Maps `crate_id` of items to a crate name and html_root_url if it exists. - pub external_crates: FxHashMap, + pub external_crates: HashMap, /// A single version number to be used in the future when making backwards incompatible changes /// to the JSON output. pub format_version: u32, @@ -72,7 +72,7 @@ pub struct Item { /// Some("") if there is some documentation but it is empty (EG `#[doc = ""]`). pub docs: Option, /// This mapping resolves [intra-doc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs - pub links: FxHashMap, + pub links: HashMap, /// Stringified versions of the attributes on this item (e.g. `"#[inline]"`) pub attrs: Vec, pub deprecation: Option, diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index bfd2141d9a174..9b0603c4d55ba 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -9,9 +9,10 @@ use rustc_hir::def::CtorKind; use rustc_span::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_span::Pos; +use json_types::*; + use crate::clean; use crate::formats::item_type::ItemType; -use crate::json::types::*; use crate::json::JsonRenderer; impl JsonRenderer<'_> { @@ -22,7 +23,7 @@ impl JsonRenderer<'_> { match *kind { clean::StrippedItem(_) => None, kind => Some(Item { - id: def_id.into(), + id: from_def_id(def_id), crate_id: def_id.krate.as_u32(), name: name.map(|sym| sym.to_string()), source: self.convert_span(source), @@ -32,7 +33,7 @@ impl JsonRenderer<'_> { .links .into_iter() .filter_map(|clean::ItemLink { link, did, .. }| { - did.map(|did| (link, did.into())) + did.map(|did| (link, from_def_id(did))) }) .collect(), attrs: attrs @@ -40,7 +41,7 @@ impl JsonRenderer<'_> { .iter() .map(rustc_ast_pretty::pprust::attribute_to_string) .collect(), - deprecation: deprecation.map(Into::into), + deprecation: deprecation.map(from_deprecation), kind: item_type.into(), inner: kind.into(), }), @@ -74,19 +75,17 @@ impl JsonRenderer<'_> { Inherited => Visibility::Default, Restricted(did) if did.index == CRATE_DEF_INDEX => Visibility::Crate, Restricted(did) => Visibility::Restricted { - parent: did.into(), + parent: from_def_id(did), path: self.tcx.def_path(did).to_string_no_crate_verbose(), }, } } } -impl From for Deprecation { - fn from(deprecation: rustc_attr::Deprecation) -> Self { - #[rustfmt::skip] - let rustc_attr::Deprecation { since, note, is_since_rustc_version: _, suggestion: _ } = deprecation; - Deprecation { since: since.map(|s| s.to_string()), note: note.map(|s| s.to_string()) } - } +crate fn from_deprecation(deprecation: rustc_attr::Deprecation) -> Deprecation { + #[rustfmt::skip] + let rustc_attr::Deprecation { since, note, is_since_rustc_version: _, suggestion: _ } = deprecation; + Deprecation { since: since.map(|s| s.to_string()), note: note.map(|s| s.to_string()) } } impl From for GenericArgs { @@ -141,10 +140,8 @@ impl From for TypeBindingKind { } } -impl From for Id { - fn from(did: DefId) -> Self { - Id(format!("{}:{}", did.krate.as_u32(), u32::from(did.index))) - } +crate fn from_def_id(did: DefId) -> Id { + Id(format!("{}:{}", did.krate.as_u32(), u32::from(did.index))) } impl From for ItemEnum { @@ -199,7 +196,7 @@ impl From for Struct { fn from(struct_: clean::Struct) -> Self { let clean::Struct { struct_type, generics, fields, fields_stripped } = struct_; Struct { - struct_type: struct_type.into(), + struct_type: from_ctor_kind(struct_type), generics: generics.into(), fields_stripped, fields: ids(fields), @@ -221,13 +218,11 @@ impl From for Struct { } } -impl From for StructType { - fn from(struct_type: CtorKind) -> Self { - match struct_type { - CtorKind::Fictive => StructType::Plain, - CtorKind::Fn => StructType::Tuple, - CtorKind::Const => StructType::Unit, - } +crate fn from_ctor_kind(struct_type: CtorKind) -> StructType { + match struct_type { + CtorKind::Fictive => StructType::Plain, + CtorKind::Fn => StructType::Tuple, + CtorKind::Const => StructType::Unit, } } @@ -310,7 +305,7 @@ impl From for GenericBound { GenericBound::TraitBound { trait_: trait_.into(), generic_params: generic_params.into_iter().map(Into::into).collect(), - modifier: modifier.into(), + modifier: from_trait_bound_modifier(modifier), } } Outlives(lifetime) => GenericBound::Outlives(lifetime.0.to_string()), @@ -318,14 +313,12 @@ impl From for GenericBound { } } -impl From for TraitBoundModifier { - fn from(modifier: rustc_hir::TraitBoundModifier) -> Self { - use rustc_hir::TraitBoundModifier::*; - match modifier { - None => TraitBoundModifier::None, - Maybe => TraitBoundModifier::Maybe, - MaybeConst => TraitBoundModifier::MaybeConst, - } +crate fn from_trait_bound_modifier(modifier: rustc_hir::TraitBoundModifier) -> TraitBoundModifier { + use rustc_hir::TraitBoundModifier::*; + match modifier { + None => TraitBoundModifier::None, + Maybe => TraitBoundModifier::Maybe, + MaybeConst => TraitBoundModifier::MaybeConst, } } @@ -335,7 +328,7 @@ impl From for Type { match ty { ResolvedPath { path, param_names, did, is_generic: _ } => Type::ResolvedPath { name: path.whole_name(), - id: did.into(), + id: from_def_id(did), args: path.segments.last().map(|args| Box::new(args.clone().args.into())), param_names: param_names .map(|v| v.into_iter().map(Into::into).collect()) @@ -470,7 +463,7 @@ impl From for Struct { fn from(struct_: clean::VariantStruct) -> Self { let clean::VariantStruct { struct_type, fields, fields_stripped } = struct_; Struct { - struct_type: struct_type.into(), + struct_type: from_ctor_kind(struct_type), generics: Default::default(), fields_stripped, fields: ids(fields), @@ -497,13 +490,13 @@ impl From for Import { Simple(s) => Import { span: import.source.path.whole_name(), name: s.to_string(), - id: import.source.did.map(Into::into), + id: import.source.did.map(from_def_id), glob: false, }, Glob => Import { span: import.source.path.whole_name(), name: import.source.path.last_name().to_string(), - id: import.source.did.map(Into::into), + id: import.source.did.map(from_def_id), glob: true, }, } @@ -513,20 +506,18 @@ impl From for Import { impl From for ProcMacro { fn from(mac: clean::ProcMacro) -> Self { ProcMacro { - kind: mac.kind.into(), + kind: from_macro_kind(mac.kind), helpers: mac.helpers.iter().map(|x| x.to_string()).collect(), } } } -impl From for MacroKind { - fn from(kind: rustc_span::hygiene::MacroKind) -> Self { - use rustc_span::hygiene::MacroKind::*; - match kind { - Bang => MacroKind::Bang, - Attr => MacroKind::Attr, - Derive => MacroKind::Derive, - } +crate fn from_macro_kind(kind: rustc_span::hygiene::MacroKind) -> MacroKind { + use rustc_span::hygiene::MacroKind::*; + match kind { + Bang => MacroKind::Bang, + Attr => MacroKind::Attr, + Derive => MacroKind::Derive, } } @@ -599,5 +590,5 @@ impl From for ItemKind { } fn ids(items: impl IntoIterator) -> Vec { - items.into_iter().filter(|x| !x.is_stripped()).map(|i| i.def_id.into()).collect() + items.into_iter().filter(|x| !x.is_stripped()).map(|i| from_def_id(i.def_id)).collect() } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index dc50c8a76b24f..8acfa3cc08a5b 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -5,7 +5,6 @@ //! docs for usage and details. mod conversions; -pub mod types; use std::cell::RefCell; use std::fs::File; @@ -17,12 +16,15 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; +use json_types as types; + use crate::clean; use crate::config::{RenderInfo, RenderOptions}; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::FormatRenderer; use crate::html::render::cache::ExternalLocation; +use crate::json::conversions::from_def_id; #[derive(Clone)] crate struct JsonRenderer<'tcx> { @@ -53,7 +55,7 @@ impl JsonRenderer<'_> { .map(|i| { let item = &i.impl_item; self.item(item.clone(), cache).unwrap(); - item.def_id.into() + from_def_id(item.def_id) }) .collect() }) @@ -71,7 +73,7 @@ impl JsonRenderer<'_> { let item = &i.impl_item; if item.def_id.is_local() { self.item(item.clone(), cache).unwrap(); - Some(item.def_id.into()) + Some(from_def_id(item.def_id)) } else { None } @@ -90,9 +92,9 @@ impl JsonRenderer<'_> { if !id.is_local() { trait_item.items.clone().into_iter().for_each(|i| self.item(i, cache).unwrap()); Some(( - id.into(), + from_def_id(id), types::Item { - id: id.into(), + id: from_def_id(id), crate_id: id.krate.as_u32(), name: cache .paths @@ -160,7 +162,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { } else if let types::ItemEnum::EnumItem(ref mut e) = new_item.inner { e.impls = self.get_impls(id, cache) } - let removed = self.index.borrow_mut().insert(id.into(), new_item.clone()); + let removed = self.index.borrow_mut().insert(from_def_id(id), new_item.clone()); // FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check // to make sure the items are unique. if let Some(old_item) = removed { @@ -208,11 +210,18 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { debug!("Done with crate"); let mut index = (*self.index).clone().into_inner(); index.extend(self.get_trait_items(cache)); + let len = index.len(); let output = types::Crate { root: types::Id(String::from("0:0")), crate_version: krate.version.clone(), includes_private: cache.document_private, - index, + index: index.into_iter().fold( + std::collections::HashMap::with_capacity(len), + |mut acc, (key, val)| { + acc.insert(key, val); + acc + }, + ), paths: cache .paths .clone() @@ -220,7 +229,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .chain(cache.external_paths.clone().into_iter()) .map(|(k, (path, kind))| { ( - k.into(), + from_def_id(k), types::ItemSummary { crate_id: k.krate.as_u32(), path, kind: kind.into() }, ) }) From bb65513a71e7e052e87b7b91f816d585e0ad8d37 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 22 Jan 2021 16:30:44 -0500 Subject: [PATCH 2/7] Update cargo.lock --- Cargo.lock | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b2ae22b6abd9b..086dd6b4efe5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1636,6 +1636,13 @@ version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5" +[[package]] +name = "json-types" +version = "0.1.0" +dependencies = [ + "serde", +] + [[package]] name = "jsondocck" version = "0.1.0" @@ -4387,6 +4394,7 @@ version = "0.0.0" dependencies = [ "expect-test", "itertools 0.9.0", + "json-types", "minifier", "pulldown-cmark 0.8.0", "regex", From d6909e11cd0f5e054004a60b22efaad5f43ec929 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 22 Jan 2021 16:46:19 -0500 Subject: [PATCH 3/7] Allow rustc::default_hash_types in the offending statement --- src/librustdoc/json/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 8acfa3cc08a5b..c9d552fe47da6 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -211,6 +211,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { let mut index = (*self.index).clone().into_inner(); index.extend(self.get_trait_items(cache)); let len = index.len(); + // This needs to be the default HashMap for compatibility with the public interface for + // rustdoc-json + #[allow(rustc::default_hash_types)] let output = types::Crate { root: types::Id(String::from("0:0")), crate_version: krate.version.clone(), From 1a78a8903868adac497345da50619fabc8a17f0f Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 22 Jan 2021 17:42:15 -0500 Subject: [PATCH 4/7] Move into src/etc --- Cargo.toml | 2 +- src/{librustdoc => etc}/json-types/Cargo.toml | 0 src/{librustdoc => etc}/json-types/lib.rs | 0 src/librustdoc/Cargo.toml | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename src/{librustdoc => etc}/json-types/Cargo.toml (100%) rename src/{librustdoc => etc}/json-types/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 5b58ed8f6a050..34d3718f57db0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "compiler/rustc", "library/std", "library/test", - "src/librustdoc/json-types", + "src/etc/json-types", "src/tools/cargotest", "src/tools/clippy", "src/tools/compiletest", diff --git a/src/librustdoc/json-types/Cargo.toml b/src/etc/json-types/Cargo.toml similarity index 100% rename from src/librustdoc/json-types/Cargo.toml rename to src/etc/json-types/Cargo.toml diff --git a/src/librustdoc/json-types/lib.rs b/src/etc/json-types/lib.rs similarity index 100% rename from src/librustdoc/json-types/lib.rs rename to src/etc/json-types/lib.rs diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index bc6eba74d2d48..560bca8e3d116 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -17,7 +17,7 @@ smallvec = "1.0" tempfile = "3" itertools = "0.9" regex = "1" -json-types = { path = "./json-types" } +json-types = { path = "../etc/json-types" } [dev-dependencies] expect-test = "1.0" From c28427ae8aa21bc329db82a62d0f449a116f01d7 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 22 Jan 2021 18:30:01 -0500 Subject: [PATCH 5/7] Simplify conversion --- src/librustdoc/json/mod.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index c9d552fe47da6..dd9aced3121f3 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -210,21 +210,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { debug!("Done with crate"); let mut index = (*self.index).clone().into_inner(); index.extend(self.get_trait_items(cache)); - let len = index.len(); - // This needs to be the default HashMap for compatibility with the public interface for - // rustdoc-json - #[allow(rustc::default_hash_types)] let output = types::Crate { root: types::Id(String::from("0:0")), crate_version: krate.version.clone(), includes_private: cache.document_private, - index: index.into_iter().fold( - std::collections::HashMap::with_capacity(len), - |mut acc, (key, val)| { - acc.insert(key, val); - acc - }, - ), + index: index.into_iter().collect(), paths: cache .paths .clone() From 36284a33f5500a1ff46e02f3f279131e28c871c8 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Sun, 24 Jan 2021 15:42:33 -0500 Subject: [PATCH 6/7] `src/etc/json-types` -> `src/rustdoc-json-types` --- Cargo.toml | 2 +- src/librustdoc/Cargo.toml | 2 +- src/{etc/json-types => rustdoc-json-types}/Cargo.toml | 0 src/{etc/json-types => rustdoc-json-types}/lib.rs | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename src/{etc/json-types => rustdoc-json-types}/Cargo.toml (100%) rename src/{etc/json-types => rustdoc-json-types}/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 34d3718f57db0..f3b2e0f740d61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "compiler/rustc", "library/std", "library/test", - "src/etc/json-types", + "src/rustdoc-json-types", "src/tools/cargotest", "src/tools/clippy", "src/tools/compiletest", diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 560bca8e3d116..c33482251ed4a 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -17,7 +17,7 @@ smallvec = "1.0" tempfile = "3" itertools = "0.9" regex = "1" -json-types = { path = "../etc/json-types" } +json-types = { path = "../rustdoc-json-types" } [dev-dependencies] expect-test = "1.0" diff --git a/src/etc/json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml similarity index 100% rename from src/etc/json-types/Cargo.toml rename to src/rustdoc-json-types/Cargo.toml diff --git a/src/etc/json-types/lib.rs b/src/rustdoc-json-types/lib.rs similarity index 100% rename from src/etc/json-types/lib.rs rename to src/rustdoc-json-types/lib.rs From 6cbc4c234e8999702a4dc3220d585a849e1dd374 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Mon, 25 Jan 2021 16:23:43 -0500 Subject: [PATCH 7/7] Update crate name and add README --- Cargo.lock | 16 ++++++++-------- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/json/conversions.rs | 2 +- src/librustdoc/json/mod.rs | 2 +- src/rustdoc-json-types/Cargo.toml | 2 +- src/rustdoc-json-types/README.md | 12 ++++++++++++ 6 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 src/rustdoc-json-types/README.md diff --git a/Cargo.lock b/Cargo.lock index 086dd6b4efe5a..63afb2a7d73c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1636,13 +1636,6 @@ version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5" -[[package]] -name = "json-types" -version = "0.1.0" -dependencies = [ - "serde", -] - [[package]] name = "jsondocck" version = "0.1.0" @@ -4394,17 +4387,24 @@ version = "0.0.0" dependencies = [ "expect-test", "itertools 0.9.0", - "json-types", "minifier", "pulldown-cmark 0.8.0", "regex", "rustc-rayon", + "rustdoc-json-types", "serde", "serde_json", "smallvec 1.4.2", "tempfile", ] +[[package]] +name = "rustdoc-json-types" +version = "0.1.0" +dependencies = [ + "serde", +] + [[package]] name = "rustdoc-themes" version = "0.1.0" diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index c33482251ed4a..db64b31f31cfc 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -17,7 +17,7 @@ smallvec = "1.0" tempfile = "3" itertools = "0.9" regex = "1" -json-types = { path = "../rustdoc-json-types" } +rustdoc-json-types = { path = "../rustdoc-json-types" } [dev-dependencies] expect-test = "1.0" diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 9b0603c4d55ba..b2e5c8834b8ff 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -9,7 +9,7 @@ use rustc_hir::def::CtorKind; use rustc_span::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_span::Pos; -use json_types::*; +use rustdoc_json_types::*; use crate::clean; use crate::formats::item_type::ItemType; diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index dd9aced3121f3..92ba41c1b3b62 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -16,7 +16,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; -use json_types as types; +use rustdoc_json_types as types; use crate::clean; use crate::config::{RenderInfo, RenderOptions}; diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml index b9c97c31c1877..7bba16a68b96c 100644 --- a/src/rustdoc-json-types/Cargo.toml +++ b/src/rustdoc-json-types/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "json-types" +name = "rustdoc-json-types" version = "0.1.0" authors = ["The Rust Project Developers"] edition = "2018" diff --git a/src/rustdoc-json-types/README.md b/src/rustdoc-json-types/README.md new file mode 100644 index 0000000000000..17894c3c61d03 --- /dev/null +++ b/src/rustdoc-json-types/README.md @@ -0,0 +1,12 @@ +# Rustdoc JSON Types + +This crate exposes the Rustdoc JSON API as a set of types with serde implementations. +These types are part of the public interface of the rustdoc JSON output, and making them +their own crate allows them to be versioned and distributed without having to depend on +any rustc/rustdoc internals. This way, consumers can rely on this crate for both documentation +of the output, and as a way to read the output easily, and its versioning is intended to +follow semver guarantees about the version of the format. JSON format X will always be +compatible with rustdoc-json-types version N. + +Currently, this crate is only used by rustdoc itself. Upon the stabilization of +rustdoc-json, it may be start to be distributed separately for consumers of the API.