diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-07-09 00:35:55 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-07-27 21:07:37 +0200 |
| commit | d8cf8ba5f7e4154913eab3be13fd1cc0b3e06906 (patch) | |
| tree | 8e093ee89a15a1252ba76ebc041861210ee74325 /src/librustdoc | |
| parent | 52af82bdb9bdf2ee481fee82c63993807f771119 (diff) | |
introduce PredicateAtom
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 48 | ||||
| -rw-r--r-- | src/librustdoc/clean/simplify.rs | 4 |
3 files changed, 27 insertions, 35 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 498fa25836c..98d8f100b27 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -315,11 +315,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { tcx: TyCtxt<'tcx>, pred: ty::Predicate<'tcx>, ) -> FxHashSet<GenericParamDef> { - let regions = match pred.ignore_quantifiers().skip_binder().kind() { - &ty::PredicateKind::Trait(poly_trait_pred, _) => { + let regions = match pred.skip_binders() { + ty::PredicateAtom::Trait(poly_trait_pred, _) => { tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(poly_trait_pred)) } - &ty::PredicateKind::Projection(poly_proj_pred) => { + ty::PredicateAtom::Projection(poly_proj_pred) => { tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(poly_proj_pred)) } _ => return FxHashSet::default(), @@ -465,8 +465,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .iter() .filter(|p| { !orig_bounds.contains(p) - || match p.ignore_quantifiers().skip_binder().kind() { - ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait, + || match p.skip_binders() { + ty::PredicateAtom::Trait(pred, _) => pred.def_id() == sized_trait, _ => false, } }) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a86ee12fa99..728453deecf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -480,19 +480,18 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> { impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> { fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> { - match self.ignore_quantifiers().skip_binder().kind() { - &ty::PredicateKind::Trait(pred, _) => Some(ty::Binder::bind(pred).clean(cx)), - &ty::PredicateKind::Subtype(pred) => Some(ty::Binder::bind(pred).clean(cx)), - &ty::PredicateKind::RegionOutlives(pred) => ty::Binder::bind(pred).clean(cx), - &ty::PredicateKind::TypeOutlives(pred) => ty::Binder::bind(pred).clean(cx), - &ty::PredicateKind::Projection(pred) => Some(ty::Binder::bind(pred).clean(cx)), + match self.skip_binders() { + ty::PredicateAtom::Trait(pred, _) => Some(ty::Binder::bind(pred).clean(cx)), + ty::PredicateAtom::Subtype(pred) => Some(ty::Binder::bind(pred).clean(cx)), + ty::PredicateAtom::RegionOutlives(pred) => ty::Binder::bind(pred).clean(cx), + ty::PredicateAtom::TypeOutlives(pred) => ty::Binder::bind(pred).clean(cx), + ty::PredicateAtom::Projection(pred) => Some(ty::Binder::bind(pred).clean(cx)), - ty::PredicateKind::ForAll(_) => panic!("unexpected predicate: {:?}", self), - ty::PredicateKind::WellFormed(..) - | ty::PredicateKind::ObjectSafe(..) - | ty::PredicateKind::ClosureKind(..) - | ty::PredicateKind::ConstEvaluatable(..) - | ty::PredicateKind::ConstEquate(..) => panic!("not user writable"), + ty::PredicateAtom::WellFormed(..) + | ty::PredicateAtom::ObjectSafe(..) + | ty::PredicateAtom::ClosureKind(..) + | ty::PredicateAtom::ConstEvaluatable(..) + | ty::PredicateAtom::ConstEquate(..) => panic!("not user writable"), } } } @@ -755,18 +754,18 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx .flat_map(|(p, _)| { let mut projection = None; let param_idx = (|| { - match p.ignore_quantifiers().skip_binder().kind() { - &ty::PredicateKind::Trait(pred, _constness) => { + match p.skip_binders() { + ty::PredicateAtom::Trait(pred, _constness) => { if let ty::Param(param) = pred.self_ty().kind { return Some(param.index); } } - &ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => { + ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => { if let ty::Param(param) = ty.kind { return Some(param.index); } } - &ty::PredicateKind::Projection(p) => { + ty::PredicateAtom::Projection(p) => { if let ty::Param(param) = p.projection_ty.self_ty().kind { projection = Some(ty::Binder::bind(p)); return Some(param.index); @@ -1663,15 +1662,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { .filter_map(|predicate| { // Note: The substs of opaque types can contain unbound variables, // meaning that we have to use `ignore_quantifiers_with_unbound_vars` here. - let trait_ref = match predicate - .ignore_quantifiers_with_unbound_vars(cx.tcx) - .skip_binder() - .kind() - { - ty::PredicateKind::Trait(tr, _constness) => { + let trait_ref = match predicate.bound_atom(cx.tcx).skip_binder() { + ty::PredicateAtom::Trait(tr, _constness) => { ty::Binder::bind(tr.trait_ref) } - ty::PredicateKind::TypeOutlives(pred) => { + ty::PredicateAtom::TypeOutlives(pred) => { if let Some(r) = pred.1.clean(cx) { regions.push(GenericBound::Outlives(r)); } @@ -1691,10 +1686,9 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { .predicates .iter() .filter_map(|pred| { - if let ty::PredicateKind::Projection(proj) = pred - .ignore_quantifiers_with_unbound_vars(cx.tcx) - .skip_binder() - .kind() + // We never rebind `proj`, so `skip_binders_unchecked` is safe here. + if let ty::PredicateAtom::Projection(proj) = + pred.skip_binders_unchecked() { if proj.projection_ty.trait_ref(cx.tcx) == trait_ref.skip_binder() diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 98e461fe695..0f995a60c22 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -141,9 +141,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId) .predicates .iter() .filter_map(|(pred, _)| { - if let ty::PredicateKind::Trait(pred, _) = - pred.ignore_quantifiers().skip_binder().kind() - { + if let ty::PredicateAtom::Trait(pred, _) = pred.skip_binders() { if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None } } else { None |
