impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
- match self.kind() {
- ty::PredicateKind::Trait(ref pred, _) => Some(pred.clean(cx)),
- ty::PredicateKind::Subtype(ref pred) => Some(pred.clean(cx)),
- ty::PredicateKind::RegionOutlives(ref pred) => pred.clean(cx),
- ty::PredicateKind::TypeOutlives(ref pred) => pred.clean(cx),
- ty::PredicateKind::Projection(ref pred) => Some(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::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"),
}
}
}
.flat_map(|(p, _)| {
let mut projection = None;
let param_idx = (|| {
- if let Some(trait_ref) = p.to_opt_poly_trait_ref() {
- if let ty::Param(param) = trait_ref.skip_binder().self_ty().kind {
- return Some(param.index);
+ match p.skip_binders() {
+ ty::PredicateAtom::Trait(pred, _constness) => {
+ if let ty::Param(param) = pred.self_ty().kind {
+ return Some(param.index);
+ }
}
- } else if let Some(outlives) = p.to_opt_type_outlives() {
- if let ty::Param(param) = outlives.skip_binder().0.kind {
- return Some(param.index);
+ ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
+ if let ty::Param(param) = ty.kind {
+ return Some(param.index);
+ }
}
- } else if let ty::PredicateKind::Projection(p) = p.kind() {
- if let ty::Param(param) = p.skip_binder().projection_ty.self_ty().kind {
- projection = Some(p);
- return Some(param.index);
+ 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);
+ }
}
+ _ => (),
}
None
impl Clean<Item> for doctree::Trait<'_> {
fn clean(&self, cx: &DocContext<'_>) -> Item {
let attrs = self.attrs.clean(cx);
+ let is_spotlight = attrs.has_doc_flag(sym::spotlight);
Item {
name: Some(self.name.clean(cx)),
attrs,
items: self.items.iter().map(|ti| ti.clean(cx)).collect(),
generics: self.generics.clean(cx),
bounds: self.bounds.clean(cx),
+ is_spotlight,
is_auto: self.is_auto.clean(cx),
}),
}
.predicates
.iter()
.filter_map(|predicate| {
- let trait_ref = if let Some(tr) = predicate.to_opt_poly_trait_ref() {
- tr
- } else if let ty::PredicateKind::TypeOutlives(pred) = predicate.kind() {
- // these should turn up at the end
- if let Some(r) = pred.skip_binder().1.clean(cx) {
- regions.push(GenericBound::Outlives(r));
+ // 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.bound_atom(cx.tcx).skip_binder() {
+ ty::PredicateAtom::Trait(tr, _constness) => {
+ ty::Binder::bind(tr.trait_ref)
}
- return None;
- } else {
- return None;
+ ty::PredicateAtom::TypeOutlives(pred) => {
+ if let Some(r) = pred.1.clean(cx) {
+ regions.push(GenericBound::Outlives(r));
+ }
+ return None;
+ }
+ _ => return None,
};
if let Some(sized) = cx.tcx.lang_items().sized_trait() {
.predicates
.iter()
.filter_map(|pred| {
- if let ty::PredicateKind::Projection(proj) = pred.kind() {
- let proj = proj.skip_binder();
+ // 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()
{
attr::Stable { ref since } => since.to_string(),
_ => String::new(),
},
- deprecation: self.rustc_depr.as_ref().map(|d| Deprecation {
- note: Some(d.reason.to_string()).filter(|r| !r.is_empty()),
- since: Some(d.since.to_string()).filter(|d| !d.is_empty()),
- }),
unstable_reason: match self.level {
attr::Unstable { reason: Some(ref reason), .. } => Some(reason.to_string()),
_ => None,
Deprecation {
since: self.since.map(|s| s.to_string()).filter(|s| !s.is_empty()),
note: self.note.map(|n| n.to_string()).filter(|n| !n.is_empty()),
+ is_since_rustc_version: self.is_since_rustc_version,
}
}
}