about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-03-17 10:46:38 -0700
committerGitHub <noreply@github.com>2023-03-17 10:46:38 -0700
commit7f76084933b69ae856bc872c3eecdc2378a21f4b (patch)
treea26d74903d318b2798fa397819b5e4cf1d61ea3a
parentbfb66eb4bb4ada8a0b4d48d73a93e8f5df0e54be (diff)
downloadrust-7f76084933b69ae856bc872c3eecdc2378a21f4b.tar.gz
rust-7f76084933b69ae856bc872c3eecdc2378a21f4b.zip
Add clarifying comments
-rw-r--r--src/librustdoc/clean/types.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 1b8478ee21c..7dbb3f76a0a 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -1496,6 +1496,8 @@ impl Type {
     /// An owned type is also the same as its borrowed variants (this is commutative),
     /// but `&T` is not the same as `&mut T`.
     pub(crate) fn is_doc_subtype_of(&self, other: &Self, cache: &Cache) -> bool {
+        // Strip the references so that it can compare the actual types, unless both are references.
+        // If both are references, leave them alone and compare the mutabilities later.
         let (self_cleared, other_cleared) = if !self.is_borrowed_ref() || !other.is_borrowed_ref() {
             (self.without_borrowed_ref(), other.without_borrowed_ref())
         } else {
@@ -1518,6 +1520,7 @@ impl Type {
             // Placeholders are equal to all other types.
             (Type::Infer, _) | (_, Type::Infer) => true,
             // Generics match everything on the right, but not on the left.
+            // If both sides are generic, this returns true.
             (_, Type::Generic(_)) => true,
             (Type::Generic(_), _) => false,
             // Paths account for both the path itself and its generics.