Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b8351c3

Browse files
committed
Avoid unnecessary matches by changing Clean impl
1 parent 91d3b72 commit b8351c3

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
118118
span: Span::dummy(),
119119
unsafety: hir::Unsafety::Normal,
120120
generics: new_generics,
121-
trait_: Some(trait_ref.clean(self.cx).get_trait_path().unwrap()),
121+
trait_: Some(trait_ref.clean(self.cx)),
122122
for_: ty.clean(self.cx),
123123
items: Vec::new(),
124124
negative_polarity,

src/librustdoc/clean/blanket_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
114114
.clean(self.cx),
115115
// FIXME(eddyb) compute both `trait_` and `for_` from
116116
// the post-inference `trait_ref`, as it's more accurate.
117-
trait_: Some(trait_ref.clean(self.cx).get_trait_path().unwrap()),
117+
trait_: Some(trait_ref.clean(self.cx)),
118118
for_: ty.clean(self.cx),
119119
items: self
120120
.cx

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,7 @@ crate fn build_impl(
446446
),
447447
};
448448
let polarity = tcx.impl_polarity(did);
449-
let trait_ = associated_trait.clean(cx).map(|bound| match bound {
450-
clean::GenericBound::TraitBound(polyt, _) => polyt.trait_,
451-
clean::GenericBound::Outlives(..) => unreachable!(),
452-
});
449+
let trait_ = associated_trait.clean(cx);
453450
if trait_.def_id() == tcx.lang_items().deref_trait() {
454451
super::build_deref_target_impls(cx, &trait_items, ret);
455452
}

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,9 @@ impl Clean<Path> for (ty::TraitRef<'_>, &[TypeBinding]) {
172172
}
173173
}
174174

175-
impl<'tcx> Clean<GenericBound> for ty::TraitRef<'tcx> {
176-
fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound {
177-
GenericBound::TraitBound(
178-
PolyTrait { trait_: (*self, &[][..]).clean(cx), generic_params: vec![] },
179-
hir::TraitBoundModifier::None,
180-
)
175+
impl Clean<Path> for ty::TraitRef<'tcx> {
176+
fn clean(&self, cx: &mut DocContext<'_>) -> Path {
177+
(*self, &[][..]).clean(cx)
181178
}
182179
}
183180

@@ -384,10 +381,7 @@ impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
384381
impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
385382
fn clean(&self, cx: &mut DocContext<'_>) -> Type {
386383
let lifted = self.lift_to_tcx(cx.tcx).unwrap();
387-
let trait_ = match lifted.trait_ref(cx.tcx).clean(cx) {
388-
GenericBound::TraitBound(t, _) => t.trait_,
389-
GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
390-
};
384+
let trait_ = lifted.trait_ref(cx.tcx).clean(cx);
391385
let self_type = self.self_ty().clean(cx);
392386
Type::QPath {
393387
name: cx.tcx.associated_item(self.item_def_id).ident.name,

0 commit comments

Comments
 (0)