-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustdoc: render <Self as X>::Y
type casts properly
#85479
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
Conversation
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
Type::QPath { | ||
name: cx.tcx.associated_item(self.item_def_id).ident.name, | ||
self_type: box self.self_ty().clean(cx), | ||
self_def_id: self_type.def_id(), | ||
self_type: box self_type, |
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.
Why add a separate def_id
field? You can just call self_type.def_id()
wherever you need it.
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.
because self_type
is a Generic(Symbol("Self"))
most of the time, and it was much easier to pass is that way. I also have a git stash that adds a new Type
called SelfType
, but it was much more work to implement and still has some bugs.
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 personally feel a bit uncomfortable with the added field, would it make sense to add a helper function/method somewhere instead?
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.
The only reason the field exists that the DefId
of the Self
type is lost after cleaning because the Self
generic parameter is resolved to Generic("Self")
, which does not contain any DefId
, but a DefId
is required to check if the cast should be displayed.
I don't know how a new helper function would help with that.
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.
Ahh, sorry, I misread your above comment. Request withdrawn.
@bors r+ |
📌 Commit d637ed4 has been approved by |
☀️ Test successful - checks-actions |
Rustdoc didn't render any
<Self as X>
casts which causes invalid code inside the documentation. This is fixed by this PR by checking if the target typeX
is different fromSelf
, and if so, it will render a typecast.Resolves #85454