Rollup merge of #88895 - camelid:cleanup-pt2, r=jyn514

rustdoc: Cleanup `clean` part 2

Split out from #88379. This contains the following commits from that PR:

- Remove `Type::ResolvedPath.is_generic`
- Rename `is_generic()` to `is_assoc_ty()`

r? `@jyn514`
This commit is contained in:
Manish Goregaokar 2021-09-25 18:22:17 -07:00 committed by GitHub
commit 7777f952f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 79 deletions

View file

@ -752,9 +752,9 @@ fn fmt_type<'cx>(
match *t {
clean::Generic(name) => write!(f, "{}", name),
clean::ResolvedPath { did, ref path, is_generic } => {
clean::ResolvedPath { did, ref path } => {
// Paths like `T::Output` and `Self::Output` should be rendered with all segments.
resolved_path(f, did, path, is_generic, use_absolute, cx)
resolved_path(f, did, path, path.is_assoc_ty(), use_absolute, cx)
}
clean::DynTrait(ref bounds, ref lt) => {
f.write_str("dyn ")?;
@ -825,28 +825,17 @@ fn fmt_type<'cx>(
hir::Mutability::Mut => "mut",
hir::Mutability::Not => "const",
};
match **t {
clean::Generic(_) | clean::ResolvedPath { is_generic: true, .. } => {
if f.alternate() {
primitive_link(
f,
clean::PrimitiveType::RawPointer,
&format!("*{} {:#}", m, t.print(cx)),
cx,
)
} else {
primitive_link(
f,
clean::PrimitiveType::RawPointer,
&format!("*{} {}", m, t.print(cx)),
cx,
)
}
}
_ => {
primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{} ", m), cx)?;
fmt::Display::fmt(&t.print(cx), f)
}
if matches!(**t, clean::Generic(_)) || t.is_assoc_ty() {
let text = if f.alternate() {
format!("*{} {:#}", m, t.print(cx))
} else {
format!("*{} {}", m, t.print(cx))
};
primitive_link(f, clean::PrimitiveType::RawPointer, &text, cx)
} else {
primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{} ", m), cx)?;
fmt::Display::fmt(&t.print(cx), f)
}
}
clean::BorrowedRef { lifetime: ref l, mutability, type_: ref ty } => {

View file

@ -712,11 +712,10 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
let mut implementor_dups: FxHashMap<Symbol, (DefId, bool)> = FxHashMap::default();
for implementor in implementors {
match implementor.inner_impl().for_ {
clean::ResolvedPath { ref path, did, is_generic: false, .. }
clean::ResolvedPath { ref path, did, .. }
| clean::BorrowedRef {
type_: box clean::ResolvedPath { ref path, did, is_generic: false, .. },
..
} => {
type_: box clean::ResolvedPath { ref path, did, .. }, ..
} if !path.is_assoc_ty() => {
let &mut (prev_did, ref mut has_duplicates) =
implementor_dups.entry(path.last()).or_insert((did, false));
if prev_did != did {
@ -1410,11 +1409,12 @@ fn render_implementor(
// If there's already another implementor that has the same abridged name, use the
// full path, for example in `std::iter::ExactSizeIterator`
let use_absolute = match implementor.inner_impl().for_ {
clean::ResolvedPath { ref path, is_generic: false, .. }
| clean::BorrowedRef {
type_: box clean::ResolvedPath { ref path, is_generic: false, .. },
..
} => implementor_dups[&path.last()].1,
clean::ResolvedPath { ref path, .. }
| clean::BorrowedRef { type_: box clean::ResolvedPath { ref path, .. }, .. }
if !path.is_assoc_ty() =>
{
implementor_dups[&path.last()].1
}
_ => false,
};
render_impl(