Rename is_generic() to is_assoc_ty()

The new name is more accurate than the previous one.
This commit is contained in:
Noah Lev 2021-08-30 20:53:57 -07:00
parent 07d6454a0f
commit 1085dc2148
4 changed files with 8 additions and 8 deletions

View File

@ -1498,9 +1498,9 @@ impl Type {
}
}
crate fn is_generic(&self) -> bool {
crate fn is_assoc_ty(&self) -> bool {
match self {
ResolvedPath { path, .. } => path.is_generic(),
ResolvedPath { path, .. } => path.is_assoc_ty(),
_ => false,
}
}
@ -1990,7 +1990,7 @@ impl Path {
+ &self.segments.iter().map(|s| s.name.to_string()).collect::<Vec<_>>().join("::")
}
crate fn is_generic(&self) -> bool {
crate fn is_assoc_ty(&self) -> bool {
match self.res {
Res::SelfTy(..) if self.segments.len() != 1 => true,
Res::Def(DefKind::TyParam, _) if self.segments.len() != 1 => true,

View File

@ -754,7 +754,7 @@ fn fmt_type<'cx>(
clean::Generic(name) => write!(f, "{}", name),
clean::ResolvedPath { did, ref path } => {
// Paths like `T::Output` and `Self::Output` should be rendered with all segments.
resolved_path(f, did, path, 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 ")?;
@ -826,7 +826,7 @@ fn fmt_type<'cx>(
hir::Mutability::Not => "const",
};
if matches!(**t, clean::Generic(_)) || t.is_generic() {
if matches!(**t, clean::Generic(_)) || t.is_assoc_ty() {
let text = if f.alternate() {
format!("*{} {:#}", m, t.print(cx))
} else {

View File

@ -715,7 +715,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
clean::ResolvedPath { ref path, did, .. }
| clean::BorrowedRef {
type_: box clean::ResolvedPath { ref path, did, .. }, ..
} if !path.is_generic() => {
} 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 {
@ -1411,7 +1411,7 @@ fn render_implementor(
let use_absolute = match implementor.inner_impl().for_ {
clean::ResolvedPath { ref path, .. }
| clean::BorrowedRef { type_: box clean::ResolvedPath { ref path, .. }, .. }
if !path.is_generic() =>
if !path.is_assoc_ty() =>
{
implementor_dups[&path.last()].1
}

View File

@ -128,7 +128,7 @@ impl<'a> DocFolder for ImplStripper<'a> {
return None;
}
if let Some(did) = imp.for_.def_id() {
if did.is_local() && !imp.for_.is_generic() && !self.retained.contains(&did.into())
if did.is_local() && !imp.for_.is_assoc_ty() && !self.retained.contains(&did.into())
{
debug!("ImplStripper: impl item for stripped type; removing");
return None;