-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Fix outdated doc comment #144838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix outdated doc comment #144838
Conversation
@@ -1534,10 +1534,10 @@ impl Type { | |||
matches!(self, Type::Path { path: Path { res: Res::Def(DefKind::TyAlias, _), .. } }) | |||
} | |||
|
|||
/// Check if two types are "the same" for documentation purposes. | |||
/// Check if this type is a subtype of another type for documentation purposes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the current behavior of the function is closer to checking if another type is a subtype of this type (this was the argument flipping I mentioned in the original issue).
Maybe my intuition is backwards, so I would wait for a second opinion before renaming the function or anything, but at the very least it should at least have a not of how generics are handled.
/// | ||
/// This is different from `Eq`, because it knows that things like | ||
/// `Placeholder` are possible matches for everything. | ||
/// `Placeholder` and generics have special subtyping rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// `Placeholder` and generics have special subtyping rules. | |
/// `Infer` and generics have special subtyping rules. |
I'm assuming this enum variant got renamed at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did small research about this, and found this place, do you think it also will be reasonable to replace Placeholder
with Infer
here?
rust/src/librustdoc/clean/types.rs
Lines 1589 to 1590 in e1b9081
// Placeholders are equal to all other types. | |
(Type::Infer, _) | (_, Type::Infer) => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would make the comment less helpful IMO, as the name of the type is clear from the following line anyways. It's also using "Placeholders" as just a regular word, since there's no inline code block, unlike in the doc comment. The doc comment should make sense without the context of the code, this only needs to make sense in context.
This updates the documentation comment for
Type::is_doc_subtype_of
to more accurately describe its purpose as a subtyping check, rather than equalityfixes #138572
r? @tgross35