Skip to content

Commit 7bd42af

Browse files
authored
Rollup merge of rust-lang#144838 - Kivooeo:doc-subtype, r=notriddle
Fix outdated doc comment This updates the documentation comment for `Type::is_doc_subtype_of` to more accurately describe its purpose as a subtyping check, rather than equality fixes rust-lang#138572 r? `````````@tgross35`````````
2 parents d525674 + 970ac40 commit 7bd42af

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/librustdoc/clean/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,10 +1552,10 @@ impl Type {
15521552
matches!(self, Type::Path { path: Path { res: Res::Def(DefKind::TyAlias, _), .. } })
15531553
}
15541554

1555-
/// Check if two types are "the same" for documentation purposes.
1555+
/// Check if this type is a subtype of another type for documentation purposes.
15561556
///
15571557
/// This is different from `Eq`, because it knows that things like
1558-
/// `Placeholder` are possible matches for everything.
1558+
/// `Infer` and generics have special subtyping rules.
15591559
///
15601560
/// This relation is not commutative when generics are involved:
15611561
///
@@ -1566,8 +1566,8 @@ impl Type {
15661566
/// let cache = Cache::new(false);
15671567
/// let generic = Type::Generic(rustc_span::symbol::sym::Any);
15681568
/// let unit = Type::Primitive(PrimitiveType::Unit);
1569-
/// assert!(!generic.is_same(&unit, &cache));
1570-
/// assert!(unit.is_same(&generic, &cache));
1569+
/// assert!(!generic.is_doc_subtype_of(&unit, &cache));
1570+
/// assert!(unit.is_doc_subtype_of(&generic, &cache));
15711571
/// ```
15721572
///
15731573
/// An owned type is also the same as its borrowed variants (this is commutative),

0 commit comments

Comments
 (0)