rustdoc-json: Rename typedef to type alias
This commit is contained in:
parent
062d247cd7
commit
c90a5b2019
@ -235,7 +235,7 @@ struct AllTypes {
|
||||
traits: FxHashSet<ItemEntry>,
|
||||
macros: FxHashSet<ItemEntry>,
|
||||
functions: FxHashSet<ItemEntry>,
|
||||
typedefs: FxHashSet<ItemEntry>,
|
||||
type_aliases: FxHashSet<ItemEntry>,
|
||||
opaque_tys: FxHashSet<ItemEntry>,
|
||||
statics: FxHashSet<ItemEntry>,
|
||||
constants: FxHashSet<ItemEntry>,
|
||||
@ -255,7 +255,7 @@ impl AllTypes {
|
||||
traits: new_set(100),
|
||||
macros: new_set(100),
|
||||
functions: new_set(100),
|
||||
typedefs: new_set(100),
|
||||
type_aliases: new_set(100),
|
||||
opaque_tys: new_set(100),
|
||||
statics: new_set(100),
|
||||
constants: new_set(100),
|
||||
@ -279,7 +279,7 @@ impl AllTypes {
|
||||
ItemType::Trait => self.traits.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::Function => self.functions.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::TypeAlias => self.typedefs.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::TypeAlias => self.type_aliases.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::OpaqueTy => self.opaque_tys.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)),
|
||||
ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
|
||||
@ -317,7 +317,7 @@ impl AllTypes {
|
||||
if !self.functions.is_empty() {
|
||||
sections.insert(ItemSection::Functions);
|
||||
}
|
||||
if !self.typedefs.is_empty() {
|
||||
if !self.type_aliases.is_empty() {
|
||||
sections.insert(ItemSection::TypeAliases);
|
||||
}
|
||||
if !self.opaque_tys.is_empty() {
|
||||
@ -374,7 +374,7 @@ impl AllTypes {
|
||||
print_entries(f, &self.attribute_macros, ItemSection::AttributeMacros);
|
||||
print_entries(f, &self.derive_macros, ItemSection::DeriveMacros);
|
||||
print_entries(f, &self.functions, ItemSection::Functions);
|
||||
print_entries(f, &self.typedefs, ItemSection::TypeAliases);
|
||||
print_entries(f, &self.type_aliases, ItemSection::TypeAliases);
|
||||
print_entries(f, &self.trait_aliases, ItemSection::TraitAliases);
|
||||
print_entries(f, &self.opaque_tys, ItemSection::OpaqueTypes);
|
||||
print_entries(f, &self.statics, ItemSection::Statics);
|
||||
|
@ -311,7 +311,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
|
||||
StaticItem(s) => ItemEnum::Static(s.into_tcx(tcx)),
|
||||
ForeignStaticItem(s) => ItemEnum::Static(s.into_tcx(tcx)),
|
||||
ForeignTypeItem => ItemEnum::ForeignType,
|
||||
TypeAliasItem(t) => ItemEnum::Typedef(t.into_tcx(tcx)),
|
||||
TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_tcx(tcx)),
|
||||
OpaqueTyItem(t) => ItemEnum::OpaqueTy(t.into_tcx(tcx)),
|
||||
ConstantItem(c) => ItemEnum::Constant(c.into_tcx(tcx)),
|
||||
MacroItem(m) => ItemEnum::Macro(m.source),
|
||||
@ -787,10 +787,10 @@ pub(crate) fn from_macro_kind(kind: rustc_span::hygiene::MacroKind) -> MacroKind
|
||||
}
|
||||
}
|
||||
|
||||
impl FromWithTcx<Box<clean::TypeAlias>> for Typedef {
|
||||
fn from_tcx(typedef: Box<clean::TypeAlias>, tcx: TyCtxt<'_>) -> Self {
|
||||
let clean::TypeAlias { type_, generics, item_type: _ } = *typedef;
|
||||
Typedef { type_: type_.into_tcx(tcx), generics: generics.into_tcx(tcx) }
|
||||
impl FromWithTcx<Box<clean::TypeAlias>> for TypeAlias {
|
||||
fn from_tcx(type_alias: Box<clean::TypeAlias>, tcx: TyCtxt<'_>) -> Self {
|
||||
let clean::TypeAlias { type_, generics, item_type: _ } = *type_alias;
|
||||
TypeAlias { type_: type_.into_tcx(tcx), generics: generics.into_tcx(tcx) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,7 +827,7 @@ impl FromWithTcx<ItemType> for ItemKind {
|
||||
Union => ItemKind::Union,
|
||||
Enum => ItemKind::Enum,
|
||||
Function | TyMethod | Method => ItemKind::Function,
|
||||
TypeAlias => ItemKind::Typedef,
|
||||
TypeAlias => ItemKind::TypeAlias,
|
||||
OpaqueTy => ItemKind::OpaqueTy,
|
||||
Static => ItemKind::Static,
|
||||
Constant => ItemKind::Constant,
|
||||
|
@ -184,7 +184,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||
| types::ItemEnum::Variant(_)
|
||||
| types::ItemEnum::TraitAlias(_)
|
||||
| types::ItemEnum::Impl(_)
|
||||
| types::ItemEnum::Typedef(_)
|
||||
| types::ItemEnum::TypeAlias(_)
|
||||
| types::ItemEnum::OpaqueTy(_)
|
||||
| types::ItemEnum::Constant(_)
|
||||
| types::ItemEnum::Static(_)
|
||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// rustdoc format-version.
|
||||
pub const FORMAT_VERSION: u32 = 26;
|
||||
pub const FORMAT_VERSION: u32 = 27;
|
||||
|
||||
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
|
||||
/// about the language items in the local crate, as well as info about external items to allow
|
||||
@ -203,7 +203,7 @@ pub enum ItemKind {
|
||||
Enum,
|
||||
Variant,
|
||||
Function,
|
||||
Typedef,
|
||||
TypeAlias,
|
||||
OpaqueTy,
|
||||
Constant,
|
||||
Trait,
|
||||
@ -242,7 +242,7 @@ pub enum ItemEnum {
|
||||
TraitAlias(TraitAlias),
|
||||
Impl(Impl),
|
||||
|
||||
Typedef(Typedef),
|
||||
TypeAlias(TypeAlias),
|
||||
OpaqueTy(OpaqueTy),
|
||||
Constant(Constant),
|
||||
|
||||
@ -696,7 +696,7 @@ pub enum MacroKind {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Typedef {
|
||||
pub struct TypeAlias {
|
||||
#[serde(rename = "type")]
|
||||
pub type_: Type,
|
||||
pub generics: Generics,
|
||||
|
@ -148,7 +148,7 @@ impl Kind {
|
||||
ItemEnum::Trait(_) => Trait,
|
||||
ItemEnum::TraitAlias(_) => TraitAlias,
|
||||
ItemEnum::Impl(_) => Impl,
|
||||
ItemEnum::Typedef(_) => Typedef,
|
||||
ItemEnum::TypeAlias(_) => Typedef,
|
||||
ItemEnum::OpaqueTy(_) => OpaqueTy,
|
||||
ItemEnum::Constant(_) => Constant,
|
||||
ItemEnum::Static(_) => Static,
|
||||
@ -186,7 +186,7 @@ impl Kind {
|
||||
ItemKind::StructField => StructField,
|
||||
ItemKind::Trait => Trait,
|
||||
ItemKind::TraitAlias => TraitAlias,
|
||||
ItemKind::Typedef => Typedef,
|
||||
ItemKind::TypeAlias => Typedef,
|
||||
ItemKind::Union => Union,
|
||||
ItemKind::Variant => Variant,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use rustdoc_json_types::{
|
||||
Constant, Crate, DynTrait, Enum, FnDecl, Function, FunctionPointer, GenericArg, GenericArgs,
|
||||
GenericBound, GenericParamDef, Generics, Id, Impl, Import, ItemEnum, ItemSummary, Module,
|
||||
OpaqueTy, Path, Primitive, ProcMacro, Static, Struct, StructKind, Term, Trait, TraitAlias,
|
||||
Type, TypeBinding, TypeBindingKind, Typedef, Union, Variant, VariantKind, WherePredicate,
|
||||
Type, TypeAlias, TypeBinding, TypeBindingKind, Union, Variant, VariantKind, WherePredicate,
|
||||
};
|
||||
use serde_json::Value;
|
||||
|
||||
@ -99,7 +99,7 @@ impl<'a> Validator<'a> {
|
||||
ItemEnum::Trait(x) => self.check_trait(x, id),
|
||||
ItemEnum::TraitAlias(x) => self.check_trait_alias(x),
|
||||
ItemEnum::Impl(x) => self.check_impl(x, id),
|
||||
ItemEnum::Typedef(x) => self.check_typedef(x),
|
||||
ItemEnum::TypeAlias(x) => self.check_typedef(x),
|
||||
ItemEnum::OpaqueTy(x) => self.check_opaque_ty(x),
|
||||
ItemEnum::Constant(x) => self.check_constant(x),
|
||||
ItemEnum::Static(x) => self.check_static(x),
|
||||
@ -221,7 +221,7 @@ impl<'a> Validator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_typedef(&mut self, x: &'a Typedef) {
|
||||
fn check_typedef(&mut self, x: &'a TypeAlias) {
|
||||
self.check_generics(&x.generics);
|
||||
self.check_type(&x.type_);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user