From 6f931da0f6abba92f4177e11407025e2b088da65 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Jul 2021 11:18:13 -0400 Subject: [PATCH 1/2] Remove `impl Clean for {Ident, Symbol}` These were only used once, in a place where it was trivial to replace. Also, it's unclear what 'clean' would mean for these, so it seems better to be explicit. --- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/clean/mod.rs | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 7b1b23ff8e6d3..1edb855a5d63e 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -552,7 +552,7 @@ fn build_macro(cx: &mut DocContext<'_>, did: DefId, name: Symbol) -> clean::Item let source = format!( "macro_rules! {} {{\n{}}}", - name.clean(cx), + name, utils::render_macro_arms(matchers, ";") ); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b0e75493aa4dc..cc086427dd0cd 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1814,20 +1814,6 @@ impl Clean for hir::PathSegment<'_> { } } -impl Clean for Ident { - #[inline] - fn clean(&self, cx: &mut DocContext<'_>) -> String { - self.name.clean(cx) - } -} - -impl Clean for Symbol { - #[inline] - fn clean(&self, _: &mut DocContext<'_>) -> String { - self.to_string() - } -} - impl Clean for hir::BareFnTy<'_> { fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl { let (generic_params, decl) = enter_impl_trait(cx, |cx| { From b0e8b7ddf7e583e964c77476cca95dbe6ea61a1c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Jul 2021 11:40:03 -0400 Subject: [PATCH 2/2] rustdoc: Remove unused Clean impls --- src/librustdoc/clean/blanket_impl.rs | 2 +- src/librustdoc/clean/mod.rs | 45 ---------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 3f2fae1aca33b..dc60b5a1d58e1 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { visibility: Inherited, def_id: FakeDefId::new_fake(item_def_id.krate), kind: box ImplItem(Impl { - span: self.cx.tcx.def_span(impl_def_id).clean(self.cx), + span: Span::from_rustc_span(self.cx.tcx.def_span(impl_def_id)), unsafety: hir::Unsafety::Normal, generics: ( self.cx.tcx.generics_of(impl_def_id), diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cc086427dd0cd..767b14135bdfa 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -227,20 +227,6 @@ impl<'tcx> Clean for ty::PolyTraitRef<'tcx> { } } -impl<'tcx> Clean>> for InternalSubsts<'tcx> { - fn clean(&self, cx: &mut DocContext<'_>) -> Option> { - let mut v = Vec::new(); - v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives)); - v.extend(self.types().map(|t| { - GenericBound::TraitBound( - PolyTrait { trait_: t.clean(cx), generic_params: Vec::new() }, - hir::TraitBoundModifier::None, - ) - })); - if !v.is_empty() { Some(v) } else { None } - } -} - impl Clean for hir::Lifetime { fn clean(&self, cx: &mut DocContext<'_>) -> Lifetime { let def = cx.tcx.named_region(self.hir_id); @@ -296,12 +282,6 @@ impl Clean for hir::ConstArg { } } -impl Clean for ty::GenericParamDef { - fn clean(&self, _cx: &mut DocContext<'_>) -> Lifetime { - Lifetime(self.name) - } -} - impl Clean> for ty::RegionKind { fn clean(&self, _cx: &mut DocContext<'_>) -> Option { match *self { @@ -1764,12 +1744,6 @@ impl Clean for hir::VariantData<'_> { } } -impl Clean for rustc_span::Span { - fn clean(&self, _cx: &mut DocContext<'_>) -> Span { - Span::from_rustc_span(*self) - } -} - impl Clean for hir::Path<'_> { fn clean(&self, cx: &mut DocContext<'_>) -> Path { Path { @@ -2211,22 +2185,3 @@ impl Clean for hir::TypeBindingKind<'_> { } } } - -enum SimpleBound { - TraitBound(Vec, Vec, Vec, hir::TraitBoundModifier), - Outlives(Lifetime), -} - -impl From for SimpleBound { - fn from(bound: GenericBound) -> Self { - match bound.clone() { - GenericBound::Outlives(l) => SimpleBound::Outlives(l), - GenericBound::TraitBound(t, mod_) => match t.trait_ { - Type::ResolvedPath { path, .. } => { - SimpleBound::TraitBound(path.segments, Vec::new(), t.generic_params, mod_) - } - _ => panic!("Unexpected bound {:?}", bound), - }, - } - } -}