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
|
let where_predicates = preds
|
||||||
.predicates
|
.predicates
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|(p, _)| {
|
.flat_map(|(pred, _)| {
|
||||||
let mut projection = None;
|
let mut projection = None;
|
||||||
let param_idx = (|| {
|
let param_idx = (|| {
|
||||||
let bound_p = p.kind();
|
let bound_p = pred.kind();
|
||||||
match bound_p.skip_binder() {
|
match bound_p.skip_binder() {
|
||||||
ty::ClauseKind::Trait(pred) => {
|
ty::ClauseKind::Trait(pred) => {
|
||||||
if let ty::Param(param) = pred.self_ty().kind() {
|
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
|
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(
|
bounds.extend(
|
||||||
p.get_bounds()
|
pred.get_bounds()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.cloned()
|
.cloned()
|
||||||
.filter(|b| !b.is_sized_bound(cx)),
|
.filter(|b| !b.is_sized_bound(cx)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let proj = projection.map(|p| {
|
if let Some(proj) = projection
|
||||||
(
|
&& let lhs = clean_projection(proj.map_bound(|p| p.projection_ty), cx, None)
|
||||||
clean_projection(p.map_bound(|p| p.projection_ty), cx, None),
|
&& let Some((_, trait_did, name)) = lhs.projection()
|
||||||
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)))
|
|
||||||
{
|
{
|
||||||
impl_trait_proj.entry(param_idx).or_default().push((
|
impl_trait_proj.entry(param_idx).or_default().push((
|
||||||
trait_did,
|
trait_did,
|
||||||
name,
|
name,
|
||||||
*rhs,
|
proj.map_bound(|p| p.term),
|
||||||
p.get_bound_params()
|
pred.get_bound_params()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.cloned()
|
.cloned()
|
||||||
@ -863,7 +857,7 @@ fn clean_ty_generics<'tcx>(
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(p)
|
Some(pred)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -891,7 +885,7 @@ fn clean_ty_generics<'tcx>(
|
|||||||
// implicit `Sized` bound unless removed with `?Sized`.
|
// implicit `Sized` bound unless removed with `?Sized`.
|
||||||
// However, in the list of where-predicates below, `Sized` appears like a
|
// However, in the list of where-predicates below, `Sized` appears like a
|
||||||
// normal bound: It's either present (the type is sized) or
|
// 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.
|
// This is unsuitable for rendering.
|
||||||
// Thus, as a first step remove all `Sized` bounds that should be implicit.
|
// 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();
|
let mut sized_params = FxHashSet::default();
|
||||||
where_predicates.retain(|pred| {
|
where_predicates.retain(|pred| {
|
||||||
if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred
|
if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred
|
||||||
&& *g != kw::SelfUpper
|
&& *g != kw::SelfUpper
|
||||||
&& bounds.iter().any(|b| b.is_sized_bound(cx))
|
&& bounds.iter().any(|b| b.is_sized_bound(cx))
|
||||||
{
|
{
|
||||||
sized_params.insert(*g);
|
sized_params.insert(*g);
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user