Skip to content

Commit 4d4c3ab

Browse files
committed
rustdoc
1 parent f1dfc31 commit 4d4c3ab

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
315315
tcx: TyCtxt<'tcx>,
316316
pred: ty::Predicate<'tcx>,
317317
) -> FxHashSet<GenericParamDef> {
318-
let regions = match pred.kind() {
319-
ty::PredicateKind::Trait(poly_trait_pred, _) => {
320-
tcx.collect_referenced_late_bound_regions(&poly_trait_pred)
318+
let regions = match pred.ignore_qualifiers().skip_binder().kind() {
319+
&ty::PredicateKind::Trait(poly_trait_pred, _) => {
320+
tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(poly_trait_pred))
321321
}
322-
ty::PredicateKind::Projection(poly_proj_pred) => {
323-
tcx.collect_referenced_late_bound_regions(&poly_proj_pred)
322+
&ty::PredicateKind::Projection(poly_proj_pred) => {
323+
tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(poly_proj_pred))
324324
}
325325
_ => return FxHashSet::default(),
326326
};

src/librustdoc/clean/mod.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
480480

481481
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
482482
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
483-
match self.kind() {
484-
ty::PredicateKind::Trait(ref pred, _) => Some(pred.clean(cx)),
485-
ty::PredicateKind::Subtype(ref pred) => Some(pred.clean(cx)),
486-
ty::PredicateKind::RegionOutlives(ref pred) => pred.clean(cx),
487-
ty::PredicateKind::TypeOutlives(ref pred) => pred.clean(cx),
488-
ty::PredicateKind::Projection(ref pred) => Some(pred.clean(cx)),
489-
483+
match self.ignore_qualifiers().skip_binder().kind() {
484+
&ty::PredicateKind::Trait(pred, _) => Some(ty::Binder::bind(pred).clean(cx)),
485+
&ty::PredicateKind::Subtype(pred) => Some(ty::Binder::bind(pred).clean(cx)),
486+
&ty::PredicateKind::RegionOutlives(pred) => ty::Binder::bind(pred).clean(cx),
487+
&ty::PredicateKind::TypeOutlives(pred) => ty::Binder::bind(pred).clean(cx),
488+
&ty::PredicateKind::Projection(pred) => Some(ty::Binder::bind(pred).clean(cx)),
489+
490+
ty::PredicateKind::ForAll(_) => panic!("unexpected predicate: {:?}", self),
490491
ty::PredicateKind::WellFormed(..)
491492
| ty::PredicateKind::ObjectSafe(..)
492493
| ty::PredicateKind::ClosureKind(..)
@@ -754,19 +755,24 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
754755
.flat_map(|(p, _)| {
755756
let mut projection = None;
756757
let param_idx = (|| {
757-
if let Some(trait_ref) = p.to_opt_poly_trait_ref() {
758-
if let ty::Param(param) = trait_ref.skip_binder().self_ty().kind {
759-
return Some(param.index);
758+
match p.ignore_qualifiers().skip_binder().kind() {
759+
&ty::PredicateKind::Trait(pred, _constness) => {
760+
if let ty::Param(param) = pred.self_ty().kind {
761+
return Some(param.index);
762+
}
760763
}
761-
} else if let Some(outlives) = p.to_opt_type_outlives() {
762-
if let ty::Param(param) = outlives.skip_binder().0.kind {
763-
return Some(param.index);
764+
&ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
765+
if let ty::Param(param) = ty.kind {
766+
return Some(param.index);
767+
}
764768
}
765-
} else if let ty::PredicateKind::Projection(p) = p.kind() {
766-
if let ty::Param(param) = p.skip_binder().projection_ty.self_ty().kind {
767-
projection = Some(p);
768-
return Some(param.index);
769+
&ty::PredicateKind::Projection(p) => {
770+
if let ty::Param(param) = p.projection_ty.self_ty().kind {
771+
projection = Some(ty::Binder::bind(p));
772+
return Some(param.index);
773+
}
769774
}
775+
_ => (),
770776
}
771777

772778
None
@@ -1655,7 +1661,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
16551661
.filter_map(|predicate| {
16561662
let trait_ref = if let Some(tr) = predicate.to_opt_poly_trait_ref() {
16571663
tr
1658-
} else if let ty::PredicateKind::TypeOutlives(pred) = predicate.kind() {
1664+
} else if let Some(pred) = predicate.to_opt_type_outlives() {
16591665
// these should turn up at the end
16601666
if let Some(r) = pred.skip_binder().1.clean(cx) {
16611667
regions.push(GenericBound::Outlives(r));
@@ -1676,8 +1682,10 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
16761682
.predicates
16771683
.iter()
16781684
.filter_map(|pred| {
1679-
if let ty::PredicateKind::Projection(proj) = pred.kind() {
1680-
let proj = proj.skip_binder();
1685+
if let ty::PredicateKind::Projection(proj) =
1686+
pred.ignore_qualifiers().skip_binder().kind()
1687+
{
1688+
let proj = proj;
16811689
if proj.projection_ty.trait_ref(cx.tcx)
16821690
== *trait_ref.skip_binder()
16831691
{

src/librustdoc/clean/simplify.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,9 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
141141
.predicates
142142
.iter()
143143
.filter_map(|(pred, _)| {
144-
if let ty::PredicateKind::Trait(ref pred, _) = pred.kind() {
145-
if pred.skip_binder().trait_ref.self_ty() == self_ty {
146-
Some(pred.def_id())
147-
} else {
148-
None
149-
}
144+
if let ty::PredicateKind::Trait(pred, _) = pred.ignore_qualifiers().skip_binder().kind()
145+
{
146+
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
150147
} else {
151148
None
152149
}

0 commit comments

Comments
 (0)