From d11855a8ceb129c25160a7adb995087fdf799102 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 15 Jan 2021 01:17:23 -0500 Subject: [PATCH] Rename VariantKind -> Variant There's no `Variant`, so it seems silly to have `Kind`. --- src/librustdoc/clean/mod.rs | 16 ++++++++-------- src/librustdoc/clean/types.rs | 8 ++++---- src/librustdoc/fold.rs | 4 ++-- src/librustdoc/html/render/mod.rs | 12 ++++++------ src/librustdoc/json/conversions.rs | 6 +++--- src/librustdoc/passes/stripper.rs | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7aed5983be4fa..545f432def5a7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1840,11 +1840,11 @@ impl Clean for rustc_hir::VariantData<'_> { impl Clean for ty::VariantDef { fn clean(&self, cx: &DocContext<'_>) -> Item { let kind = match self.ctor_kind { - CtorKind::Const => VariantKind::CLike, - CtorKind::Fn => VariantKind::Tuple( + CtorKind::Const => Variant::CLike, + CtorKind::Fn => Variant::Tuple( self.fields.iter().map(|f| cx.tcx.type_of(f.did).clean(cx)).collect(), ), - CtorKind::Fictive => VariantKind::Struct(VariantStruct { + CtorKind::Fictive => Variant::Struct(VariantStruct { struct_type: doctree::Plain, fields_stripped: false, fields: self @@ -1868,14 +1868,14 @@ impl Clean for ty::VariantDef { } } -impl Clean for hir::VariantData<'_> { - fn clean(&self, cx: &DocContext<'_>) -> VariantKind { +impl Clean for hir::VariantData<'_> { + fn clean(&self, cx: &DocContext<'_>) -> Variant { match self { - hir::VariantData::Struct(..) => VariantKind::Struct(self.clean(cx)), + hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)), hir::VariantData::Tuple(..) => { - VariantKind::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect()) + Variant::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect()) } - hir::VariantData::Unit(..) => VariantKind::CLike, + hir::VariantData::Unit(..) => Variant::CLike, } } } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 60ed5f0f82dcf..666b11b5f806d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -237,7 +237,7 @@ impl Item { match *self.kind { StructItem(ref _struct) => Some(_struct.fields_stripped), UnionItem(ref union) => Some(union.fields_stripped), - VariantItem(VariantKind::Struct(ref vstruct)) => Some(vstruct.fields_stripped), + VariantItem(Variant::Struct(ref vstruct)) => Some(vstruct.fields_stripped), _ => None, } } @@ -323,7 +323,7 @@ crate enum ItemKind { /// A method with a body. MethodItem(Function, Option), StructFieldItem(Type), - VariantItem(VariantKind), + VariantItem(Variant), /// `fn`s from an extern block ForeignFunctionItem(Function), /// `static`s from an extern block @@ -351,7 +351,7 @@ impl ItemKind { match self { StructItem(s) => s.fields.iter(), UnionItem(u) => u.fields.iter(), - VariantItem(VariantKind::Struct(v)) => v.fields.iter(), + VariantItem(Variant::Struct(v)) => v.fields.iter(), EnumItem(e) => e.variants.iter(), TraitItem(t) => t.items.iter(), ImplItem(i) => i.items.iter(), @@ -1717,7 +1717,7 @@ crate struct Enum { } #[derive(Clone, Debug)] -crate enum VariantKind { +crate enum Variant { CLike, Tuple(Vec), Struct(VariantStruct), diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 090f7648e4e3c..b2773a29e2905 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -56,12 +56,12 @@ crate trait DocFolder: Sized { VariantItem(i) => { let i2 = i.clone(); // this clone is small match i { - VariantKind::Struct(mut j) => { + Variant::Struct(mut j) => { let num_fields = j.fields.len(); j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect(); j.fields_stripped |= num_fields != j.fields.len() || j.fields.iter().any(|f| f.is_stripped()); - VariantItem(VariantKind::Struct(j)) + VariantItem(Variant::Struct(j)) } _ => VariantItem(i2), } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 0c9bb78b9673b..2db89e8a7ca68 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -3201,8 +3201,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum let name = v.name.as_ref().unwrap(); match *v.kind { clean::VariantItem(ref var) => match var { - clean::VariantKind::CLike => write!(w, "{}", name), - clean::VariantKind::Tuple(ref tys) => { + clean::Variant::CLike => write!(w, "{}", name), + clean::Variant::Tuple(ref tys) => { write!(w, "{}(", name); for (i, ty) in tys.iter().enumerate() { if i > 0 { @@ -3212,7 +3212,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum } write!(w, ")"); } - clean::VariantKind::Struct(ref s) => { + clean::Variant::Struct(ref s) => { render_struct(w, v, None, s.struct_type, &s.fields, " ", false, cx); } }, @@ -3249,7 +3249,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum id = id, name = variant.name.as_ref().unwrap() ); - if let clean::VariantItem(clean::VariantKind::Tuple(ref tys)) = *variant.kind { + if let clean::VariantItem(clean::Variant::Tuple(ref tys)) = *variant.kind { write!(w, "("); for (i, ty) in tys.iter().enumerate() { if i > 0 { @@ -3263,8 +3263,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum document(w, cx, variant, Some(it)); document_non_exhaustive(w, variant); - use crate::clean::VariantKind; - if let clean::VariantItem(VariantKind::Struct(ref s)) = *variant.kind { + use crate::clean::Variant; + if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind { let variant_id = cx.derive_id(format!( "{}.{}.fields", ItemType::Variant, diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index aa4d51f84e0bf..7d05cb016b67c 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -480,9 +480,9 @@ impl From for Struct { } } -impl From for Variant { - fn from(variant: clean::VariantKind) -> Self { - use clean::VariantKind::*; +impl From for Variant { + fn from(variant: clean::Variant) -> Self { + use clean::Variant::*; match variant { CLike => Variant::Plain, Tuple(t) => Variant::Tuple(t.into_iter().map(Into::into).collect()), diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 133849a038933..162b70973b418 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -94,7 +94,7 @@ impl<'a> DocFolder for Stripper<'a> { // implementations of traits are always public. clean::ImplItem(ref imp) if imp.trait_.is_some() => true, // Struct variant fields have inherited visibility - clean::VariantItem(clean::VariantKind::Struct(..)) => true, + clean::VariantItem(clean::Variant::Struct(..)) => true, _ => false, };