Skip to content

Commit 57e88ab

Browse files
committed
rustdoc(hack): make is_doc_subtype_of always ret true for TyAlias
it's worth noting that this function is only used in the handling of "Methods from Deref", and we were previously assuming all generic parameters were meaningless, so this is still an improvment from the status quo. this change means that we will have strictly less false positives without adding any new false negitives.
1 parent abf3832 commit 57e88ab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/librustdoc/clean/types.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,14 @@ impl Type {
15331533
matches!(self, Type::BorrowedRef { .. })
15341534
}
15351535

1536+
fn is_type_alias(&self) -> bool {
1537+
if let Type::Path { path: Path { res: Res::Def(DefKind::TyAlias, _), .. } } = &self {
1538+
true
1539+
} else {
1540+
false
1541+
}
1542+
}
1543+
15361544
/// Check if two types are "the same" for documentation purposes.
15371545
///
15381546
/// This is different from `Eq`, because it knows that things like
@@ -1561,6 +1569,16 @@ impl Type {
15611569
} else {
15621570
(self, other)
15631571
};
1572+
1573+
// FIXME: `Cache` does not have the data required to unwrap type aliases,
1574+
// so we just assume they are equal.
1575+
// This is only remotely acceptable because we were previously
1576+
// assuming all types were equal when used
1577+
// as a generic parameter of a type in `Deref::Target`.
1578+
if self_cleared.is_type_alias() || other_cleared.is_type_alias() {
1579+
return true;
1580+
}
1581+
15641582
match (self_cleared, other_cleared) {
15651583
// Recursive cases.
15661584
(Type::Tuple(a), Type::Tuple(b)) => {

0 commit comments

Comments
 (0)