Skip to content

Commit 7f76084

Browse files
authored
Add clarifying comments
1 parent bfb66eb commit 7f76084

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustdoc/clean/types.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,8 @@ impl Type {
14961496
/// An owned type is also the same as its borrowed variants (this is commutative),
14971497
/// but `&T` is not the same as `&mut T`.
14981498
pub(crate) fn is_doc_subtype_of(&self, other: &Self, cache: &Cache) -> bool {
1499+
// Strip the references so that it can compare the actual types, unless both are references.
1500+
// If both are references, leave them alone and compare the mutabilities later.
14991501
let (self_cleared, other_cleared) = if !self.is_borrowed_ref() || !other.is_borrowed_ref() {
15001502
(self.without_borrowed_ref(), other.without_borrowed_ref())
15011503
} else {
@@ -1518,6 +1520,7 @@ impl Type {
15181520
// Placeholders are equal to all other types.
15191521
(Type::Infer, _) | (_, Type::Infer) => true,
15201522
// Generics match everything on the right, but not on the left.
1523+
// If both sides are generic, this returns true.
15211524
(_, Type::Generic(_)) => true,
15221525
(Type::Generic(_), _) => false,
15231526
// Paths account for both the path itself and its generics.

0 commit comments

Comments
 (0)