rustdoc: render <Self as X>::Y type casts properly#85479
rustdoc: render <Self as X>::Y type casts properly#85479bors merged 2 commits intorust-lang:masterfrom
<Self as X>::Y type casts properly#85479Conversation
|
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
| 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.
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.
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.
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.
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.
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 typeXis different fromSelf, and if so, it will render a typecast.Resolves #85454