From a35cd415f73356b5390f2f32dfb76470e573616e Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 2 Oct 2016 19:59:48 -0400 Subject: [PATCH] Migrate `VariantKind` constructor to `Clean` impl. https://github.com/rust-lang/rust/pull/36903#discussion_r81477884 --- clean/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/clean/mod.rs b/clean/mod.rs index b3e6529..a85e019 100644 --- a/clean/mod.rs +++ b/clean/mod.rs @@ -2025,7 +2025,7 @@ impl Clean for doctree::Variant { deprecation: self.depr.clean(cx), def_id: cx.map.local_def_id(self.def.id()), inner: VariantItem(Variant { - kind: VariantKind::from_struct_def(&self.def, cx), + kind: self.def.clean(cx), }), } } @@ -2079,14 +2079,14 @@ pub enum VariantKind { StructVariant(VariantStruct), } -impl VariantKind { - fn from_struct_def(struct_def: &hir::VariantData, cx: &DocContext) -> VariantKind { - if struct_def.is_struct() { - StructVariant(struct_def.clean(cx)) - } else if struct_def.is_unit() { +impl Clean for hir::VariantData { + fn clean(&self, cx: &DocContext) -> VariantKind { + if self.is_struct() { + StructVariant(self.clean(cx)) + } else if self.is_unit() { CLikeVariant } else { - TupleVariant(struct_def.fields().iter().map(|x| x.ty.clean(cx)).collect()) + TupleVariant(self.fields().iter().map(|x| x.ty.clean(cx)).collect()) } } }