Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Kivooeo
Copy link
Contributor

@Kivooeo Kivooeo commented Aug 2, 2025

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 #138572

r? @tgross35

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 2, 2025
@@ -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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `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.

Copy link
Contributor Author

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?

// Placeholders are equal to all other types.
(Type::Infer, _) | (_, Type::Infer) => true,

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc::clean::types::Type::is_doc_subtype_of has outdated example, and arguments are flipped
4 participants