@@ -1495,7 +1495,7 @@ impl Type {
14951495 ///
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`.
1498- pub ( crate ) fn is_same ( & self , other : & Self , cache : & Cache ) -> bool {
1498+ pub ( crate ) fn is_doc_subtype_of ( & self , other : & Self , cache : & Cache ) -> bool {
14991499 let ( self_cleared, other_cleared) = if !self . is_borrowed_ref ( ) || !other. is_borrowed_ref ( ) {
15001500 ( self . without_borrowed_ref ( ) , other. without_borrowed_ref ( ) )
15011501 } else {
@@ -1504,17 +1504,17 @@ impl Type {
15041504 match ( self_cleared, other_cleared) {
15051505 // Recursive cases.
15061506 ( Type :: Tuple ( a) , Type :: Tuple ( b) ) => {
1507- a. len ( ) == b. len ( ) && a. iter ( ) . zip ( b) . all ( |( a, b) | a. is_same ( b, cache) )
1507+ a. len ( ) == b. len ( ) && a. iter ( ) . zip ( b) . all ( |( a, b) | a. is_doc_subtype_of ( b, cache) )
15081508 }
1509- ( Type :: Slice ( a) , Type :: Slice ( b) ) => a. is_same ( b, cache) ,
1510- ( Type :: Array ( a, al) , Type :: Array ( b, bl) ) => al == bl && a. is_same ( b, cache) ,
1509+ ( Type :: Slice ( a) , Type :: Slice ( b) ) => a. is_doc_subtype_of ( b, cache) ,
1510+ ( Type :: Array ( a, al) , Type :: Array ( b, bl) ) => al == bl && a. is_doc_subtype_of ( b, cache) ,
15111511 ( Type :: RawPointer ( mutability, type_) , Type :: RawPointer ( b_mutability, b_type_) ) => {
1512- mutability == b_mutability && type_. is_same ( b_type_, cache)
1512+ mutability == b_mutability && type_. is_doc_subtype_of ( b_type_, cache)
15131513 }
15141514 (
15151515 Type :: BorrowedRef { mutability, type_, .. } ,
15161516 Type :: BorrowedRef { mutability : b_mutability, type_ : b_type_, .. } ,
1517- ) => mutability == b_mutability && type_. is_same ( b_type_, cache) ,
1517+ ) => mutability == b_mutability && type_. is_doc_subtype_of ( b_type_, cache) ,
15181518 // Placeholders are equal to all other types.
15191519 ( Type :: Infer , _) | ( _, Type :: Infer ) => true ,
15201520 // Generics match everything on the right, but not on the left.
@@ -1526,7 +1526,7 @@ impl Type {
15261526 && a. generics ( )
15271527 . zip ( b. generics ( ) )
15281528 . map ( |( ag, bg) | {
1529- ag. iter ( ) . zip ( bg. iter ( ) ) . all ( |( at, bt) | at. is_same ( bt, cache) )
1529+ ag. iter ( ) . zip ( bg. iter ( ) ) . all ( |( at, bt) | at. is_doc_subtype_of ( bt, cache) )
15301530 } )
15311531 . unwrap_or ( true )
15321532 }
0 commit comments