Skip to content

Commit 86179c4

Browse files
committed
rustdoc: rename Type::is_same to is_doc_subtype_of
1 parent ee6b228 commit 86179c4

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/librustdoc/clean/types.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/librustdoc/clean/types/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ fn is_same_generic() {
7777
let cache = Cache::new(false);
7878
let generic = Type::Generic(rustc_span::symbol::sym::Any);
7979
let unit = Type::Primitive(PrimitiveType::Unit);
80-
assert!(!generic.is_same(&unit, &cache));
81-
assert!(unit.is_same(&generic, &cache));
80+
assert!(!generic.is_doc_subtype_of(&unit, &cache));
81+
assert!(unit.is_doc_subtype_of(&generic, &cache));
8282
}

src/librustdoc/html/render/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O
12911291
if let Some(impls) = cx.cache().impls.get(&did) {
12921292
for i in impls {
12931293
let impl_ = i.inner_impl();
1294-
if !ty.is_same(&impl_.for_, cx.cache()) {
1294+
if !ty.is_doc_subtype_of(&impl_.for_, cx.cache()) {
12951295
// Two different types might have the same did,
12961296
// without actually being the same.
12971297
continue;
@@ -1327,7 +1327,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
13271327

13281328
for i in impls {
13291329
let impl_ = i.inner_impl();
1330-
if !ty.is_same(&impl_.for_, cx.cache()) {
1330+
if !ty.is_doc_subtype_of(&impl_.for_, cx.cache()) {
13311331
// Two different types might have the same did,
13321332
// without actually being the same.
13331333
continue;

0 commit comments

Comments
 (0)