Remove redundant 'Variant' in variant names, stop reexporting.
This commit is contained in:
parent
88d41441f6
commit
35d214afe6
@ -12,7 +12,6 @@
|
||||
//! that clean them.
|
||||
|
||||
pub use self::Type::*;
|
||||
pub use self::VariantKind::*;
|
||||
pub use self::Mutability::*;
|
||||
pub use self::ItemEnum::*;
|
||||
pub use self::Attribute::*;
|
||||
@ -317,7 +316,7 @@ impl Item {
|
||||
match self.inner {
|
||||
StructItem(ref _struct) => Some(_struct.fields_stripped),
|
||||
UnionItem(ref union) => Some(union.fields_stripped),
|
||||
VariantItem(Variant { kind: StructVariant(ref vstruct)} ) => {
|
||||
VariantItem(Variant { kind: VariantKind::Struct(ref vstruct)} ) => {
|
||||
Some(vstruct.fields_stripped)
|
||||
},
|
||||
_ => None,
|
||||
@ -2034,14 +2033,14 @@ impl Clean<Item> for doctree::Variant {
|
||||
impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
let kind = match self.kind {
|
||||
ty::VariantKind::Unit => CLikeVariant,
|
||||
ty::VariantKind::Unit => VariantKind::CLike,
|
||||
ty::VariantKind::Tuple => {
|
||||
TupleVariant(
|
||||
VariantKind::Tuple(
|
||||
self.fields.iter().map(|f| f.unsubst_ty().clean(cx)).collect()
|
||||
)
|
||||
}
|
||||
ty::VariantKind::Struct => {
|
||||
StructVariant(VariantStruct {
|
||||
VariantKind::Struct(VariantStruct {
|
||||
struct_type: doctree::Plain,
|
||||
fields_stripped: false,
|
||||
fields: self.fields.iter().map(|field| {
|
||||
@ -2074,19 +2073,19 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum VariantKind {
|
||||
CLikeVariant,
|
||||
TupleVariant(Vec<Type>),
|
||||
StructVariant(VariantStruct),
|
||||
CLike,
|
||||
Tuple(Vec<Type>),
|
||||
Struct(VariantStruct),
|
||||
}
|
||||
|
||||
impl Clean<VariantKind> for hir::VariantData {
|
||||
fn clean(&self, cx: &DocContext) -> VariantKind {
|
||||
if self.is_struct() {
|
||||
StructVariant(self.clean(cx))
|
||||
VariantKind::Struct(self.clean(cx))
|
||||
} else if self.is_unit() {
|
||||
CLikeVariant
|
||||
VariantKind::CLike
|
||||
} else {
|
||||
TupleVariant(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
|
||||
VariantKind::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2552,8 +2551,7 @@ impl Clean<Vec<Item>> for doctree::Import {
|
||||
if remaining.is_empty() {
|
||||
return ret;
|
||||
}
|
||||
(ret, Import::List(resolve_use_source(cx, p.clean(cx), self.id),
|
||||
remaining))
|
||||
(ret, Import::List(resolve_use_source(cx, p.clean(cx), self.id), remaining))
|
||||
}
|
||||
hir::ViewPathSimple(name, ref p) => {
|
||||
if !denied {
|
||||
|
@ -74,12 +74,12 @@ pub trait DocFolder : Sized {
|
||||
VariantItem(i) => {
|
||||
let i2 = i.clone(); // this clone is small
|
||||
match i.kind {
|
||||
StructVariant(mut j) => {
|
||||
VariantKind::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(Variant {kind: StructVariant(j), ..i2})
|
||||
VariantItem(Variant {kind: VariantKind::Struct(j), ..i2})
|
||||
},
|
||||
_ => VariantItem(i2)
|
||||
}
|
||||
|
@ -2378,8 +2378,8 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
match v.inner {
|
||||
clean::VariantItem(ref var) => {
|
||||
match var.kind {
|
||||
clean::CLikeVariant => write!(w, "{}", name)?,
|
||||
clean::TupleVariant(ref tys) => {
|
||||
clean::VariantKind::CLike => write!(w, "{}", name)?,
|
||||
clean::VariantKind::Tuple(ref tys) => {
|
||||
write!(w, "{}(", name)?;
|
||||
for (i, ty) in tys.iter().enumerate() {
|
||||
if i > 0 {
|
||||
@ -2389,7 +2389,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
}
|
||||
write!(w, ")")?;
|
||||
}
|
||||
clean::StructVariant(ref s) => {
|
||||
clean::VariantKind::Struct(ref s) => {
|
||||
render_struct(w,
|
||||
v,
|
||||
None,
|
||||
@ -2429,7 +2429,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
ns_id = ns_id,
|
||||
name = variant.name.as_ref().unwrap())?;
|
||||
if let clean::VariantItem(ref var) = variant.inner {
|
||||
if let clean::TupleVariant(ref tys) = var.kind {
|
||||
if let clean::VariantKind::Tuple(ref tys) = var.kind {
|
||||
write!(w, "(")?;
|
||||
for (i, ty) in tys.iter().enumerate() {
|
||||
if i > 0 {
|
||||
@ -2443,8 +2443,10 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
write!(w, "</code></span></span>")?;
|
||||
document(w, cx, variant)?;
|
||||
|
||||
use clean::{Variant, StructVariant};
|
||||
if let clean::VariantItem( Variant { kind: StructVariant(ref s) } ) = variant.inner {
|
||||
use clean::{Variant, VariantKind};
|
||||
if let clean::VariantItem(Variant {
|
||||
kind: VariantKind::Struct(ref s)
|
||||
}) = variant.inner {
|
||||
write!(w, "<h3 class='fields'>Fields</h3>\n
|
||||
<table>")?;
|
||||
for field in &s.fields {
|
||||
|
@ -131,7 +131,7 @@ impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
clean::ImplItem(ref imp) if imp.trait_.is_some() => true,
|
||||
// Struct variant fields have inherited visibility
|
||||
clean::VariantItem(clean::Variant {
|
||||
kind: clean::StructVariant(..)
|
||||
kind: clean::VariantKind::Struct(..)
|
||||
}) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user