Skip to content

Commit 35d214a

Browse files
committed
Remove redundant 'Variant' in variant names, stop reexporting.
1 parent 88d4144 commit 35d214a

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/librustdoc/clean/mod.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//! that clean them.
1313
1414
pub use self::Type::*;
15-
pub use self::VariantKind::*;
1615
pub use self::Mutability::*;
1716
pub use self::ItemEnum::*;
1817
pub use self::Attribute::*;
@@ -317,7 +316,7 @@ impl Item {
317316
match self.inner {
318317
StructItem(ref _struct) => Some(_struct.fields_stripped),
319318
UnionItem(ref union) => Some(union.fields_stripped),
320-
VariantItem(Variant { kind: StructVariant(ref vstruct)} ) => {
319+
VariantItem(Variant { kind: VariantKind::Struct(ref vstruct)} ) => {
321320
Some(vstruct.fields_stripped)
322321
},
323322
_ => None,
@@ -2034,14 +2033,14 @@ impl Clean<Item> for doctree::Variant {
20342033
impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
20352034
fn clean(&self, cx: &DocContext) -> Item {
20362035
let kind = match self.kind {
2037-
ty::VariantKind::Unit => CLikeVariant,
2036+
ty::VariantKind::Unit => VariantKind::CLike,
20382037
ty::VariantKind::Tuple => {
2039-
TupleVariant(
2038+
VariantKind::Tuple(
20402039
self.fields.iter().map(|f| f.unsubst_ty().clean(cx)).collect()
20412040
)
20422041
}
20432042
ty::VariantKind::Struct => {
2044-
StructVariant(VariantStruct {
2043+
VariantKind::Struct(VariantStruct {
20452044
struct_type: doctree::Plain,
20462045
fields_stripped: false,
20472046
fields: self.fields.iter().map(|field| {
@@ -2074,19 +2073,19 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
20742073

20752074
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
20762075
pub enum VariantKind {
2077-
CLikeVariant,
2078-
TupleVariant(Vec<Type>),
2079-
StructVariant(VariantStruct),
2076+
CLike,
2077+
Tuple(Vec<Type>),
2078+
Struct(VariantStruct),
20802079
}
20812080

20822081
impl Clean<VariantKind> for hir::VariantData {
20832082
fn clean(&self, cx: &DocContext) -> VariantKind {
20842083
if self.is_struct() {
2085-
StructVariant(self.clean(cx))
2084+
VariantKind::Struct(self.clean(cx))
20862085
} else if self.is_unit() {
2087-
CLikeVariant
2086+
VariantKind::CLike
20882087
} else {
2089-
TupleVariant(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
2088+
VariantKind::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
20902089
}
20912090
}
20922091
}
@@ -2552,8 +2551,7 @@ impl Clean<Vec<Item>> for doctree::Import {
25522551
if remaining.is_empty() {
25532552
return ret;
25542553
}
2555-
(ret, Import::List(resolve_use_source(cx, p.clean(cx), self.id),
2556-
remaining))
2554+
(ret, Import::List(resolve_use_source(cx, p.clean(cx), self.id), remaining))
25572555
}
25582556
hir::ViewPathSimple(name, ref p) => {
25592557
if !denied {

src/librustdoc/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ pub trait DocFolder : Sized {
7474
VariantItem(i) => {
7575
let i2 = i.clone(); // this clone is small
7676
match i.kind {
77-
StructVariant(mut j) => {
77+
VariantKind::Struct(mut j) => {
7878
let num_fields = j.fields.len();
7979
j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect();
8080
j.fields_stripped |= num_fields != j.fields.len() ||
8181
j.fields.iter().any(|f| f.is_stripped());
82-
VariantItem(Variant {kind: StructVariant(j), ..i2})
82+
VariantItem(Variant {kind: VariantKind::Struct(j), ..i2})
8383
},
8484
_ => VariantItem(i2)
8585
}

src/librustdoc/html/render.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2378,8 +2378,8 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
23782378
match v.inner {
23792379
clean::VariantItem(ref var) => {
23802380
match var.kind {
2381-
clean::CLikeVariant => write!(w, "{}", name)?,
2382-
clean::TupleVariant(ref tys) => {
2381+
clean::VariantKind::CLike => write!(w, "{}", name)?,
2382+
clean::VariantKind::Tuple(ref tys) => {
23832383
write!(w, "{}(", name)?;
23842384
for (i, ty) in tys.iter().enumerate() {
23852385
if i > 0 {
@@ -2389,7 +2389,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
23892389
}
23902390
write!(w, ")")?;
23912391
}
2392-
clean::StructVariant(ref s) => {
2392+
clean::VariantKind::Struct(ref s) => {
23932393
render_struct(w,
23942394
v,
23952395
None,
@@ -2429,7 +2429,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
24292429
ns_id = ns_id,
24302430
name = variant.name.as_ref().unwrap())?;
24312431
if let clean::VariantItem(ref var) = variant.inner {
2432-
if let clean::TupleVariant(ref tys) = var.kind {
2432+
if let clean::VariantKind::Tuple(ref tys) = var.kind {
24332433
write!(w, "(")?;
24342434
for (i, ty) in tys.iter().enumerate() {
24352435
if i > 0 {
@@ -2443,8 +2443,10 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
24432443
write!(w, "</code></span></span>")?;
24442444
document(w, cx, variant)?;
24452445

2446-
use clean::{Variant, StructVariant};
2447-
if let clean::VariantItem( Variant { kind: StructVariant(ref s) } ) = variant.inner {
2446+
use clean::{Variant, VariantKind};
2447+
if let clean::VariantItem(Variant {
2448+
kind: VariantKind::Struct(ref s)
2449+
}) = variant.inner {
24482450
write!(w, "<h3 class='fields'>Fields</h3>\n
24492451
<table>")?;
24502452
for field in &s.fields {

src/librustdoc/passes/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'a> fold::DocFolder for Stripper<'a> {
131131
clean::ImplItem(ref imp) if imp.trait_.is_some() => true,
132132
// Struct variant fields have inherited visibility
133133
clean::VariantItem(clean::Variant {
134-
kind: clean::StructVariant(..)
134+
kind: clean::VariantKind::Struct(..)
135135
}) => true,
136136
_ => false,
137137
};

0 commit comments

Comments
 (0)