rustdoc: stylistic changes
This commit is contained in:
parent
c3c5a5c5f7
commit
f68f37d006
@ -798,10 +798,10 @@ fn clean_ty_generics<'tcx>(
|
||||
let where_predicates = preds
|
||||
.predicates
|
||||
.iter()
|
||||
.flat_map(|(p, _)| {
|
||||
.flat_map(|(pred, _)| {
|
||||
let mut projection = None;
|
||||
let param_idx = (|| {
|
||||
let bound_p = p.kind();
|
||||
let bound_p = pred.kind();
|
||||
match bound_p.skip_binder() {
|
||||
ty::ClauseKind::Trait(pred) => {
|
||||
if let ty::Param(param) = pred.self_ty().kind() {
|
||||
@ -826,33 +826,27 @@ fn clean_ty_generics<'tcx>(
|
||||
})();
|
||||
|
||||
if let Some(param_idx) = param_idx
|
||||
&& let Some(b) = impl_trait.get_mut(¶m_idx.into())
|
||||
&& let Some(bounds) = impl_trait.get_mut(¶m_idx.into())
|
||||
{
|
||||
let p: WherePredicate = clean_predicate(*p, cx)?;
|
||||
let pred = clean_predicate(*pred, cx)?;
|
||||
|
||||
b.extend(
|
||||
p.get_bounds()
|
||||
bounds.extend(
|
||||
pred.get_bounds()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.filter(|b| !b.is_sized_bound(cx)),
|
||||
);
|
||||
|
||||
let proj = projection.map(|p| {
|
||||
(
|
||||
clean_projection(p.map_bound(|p| p.projection_ty), cx, None),
|
||||
p.map_bound(|p| p.term),
|
||||
)
|
||||
});
|
||||
if let Some(((_, trait_did, name), rhs)) = proj
|
||||
.as_ref()
|
||||
.and_then(|(lhs, rhs): &(Type, _)| Some((lhs.projection()?, rhs)))
|
||||
if let Some(proj) = projection
|
||||
&& let lhs = clean_projection(proj.map_bound(|p| p.projection_ty), cx, None)
|
||||
&& let Some((_, trait_did, name)) = lhs.projection()
|
||||
{
|
||||
impl_trait_proj.entry(param_idx).or_default().push((
|
||||
trait_did,
|
||||
name,
|
||||
*rhs,
|
||||
p.get_bound_params()
|
||||
proj.map_bound(|p| p.term),
|
||||
pred.get_bound_params()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.cloned()
|
||||
@ -863,7 +857,7 @@ fn clean_ty_generics<'tcx>(
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(p)
|
||||
Some(pred)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@ -891,7 +885,7 @@ fn clean_ty_generics<'tcx>(
|
||||
// implicit `Sized` bound unless removed with `?Sized`.
|
||||
// However, in the list of where-predicates below, `Sized` appears like a
|
||||
// normal bound: It's either present (the type is sized) or
|
||||
// absent (the type is unsized) but never *maybe* (i.e. `?Sized`).
|
||||
// absent (the type might be unsized) but never *maybe* (i.e. `?Sized`).
|
||||
//
|
||||
// This is unsuitable for rendering.
|
||||
// Thus, as a first step remove all `Sized` bounds that should be implicit.
|
||||
@ -902,8 +896,8 @@ fn clean_ty_generics<'tcx>(
|
||||
let mut sized_params = FxHashSet::default();
|
||||
where_predicates.retain(|pred| {
|
||||
if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred
|
||||
&& *g != kw::SelfUpper
|
||||
&& bounds.iter().any(|b| b.is_sized_bound(cx))
|
||||
&& *g != kw::SelfUpper
|
||||
&& bounds.iter().any(|b| b.is_sized_bound(cx))
|
||||
{
|
||||
sized_params.insert(*g);
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user