-
Notifications
You must be signed in to change notification settings - Fork 14k
Fix ICE in rustdoc when impl is nested in a func #147911
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: main
Are you sure you want to change the base?
Conversation
206b202 to
fed595d
Compare
|
I'll side step here and let @fmease review this as they're the expert of this topic. r? fmease |
|
|
|
I’ve checked this, and yes, it fixes #147057. Updated the top post accordingly. |
fed595d to
aec6f97
Compare
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.
Thanks for looking into this! I suspect a more principled fix would be to get rid of this function and use tcx.typeck(tcx.hir_get_parent_item(hir_id).def_id) at its call-sites instead of tcx.typeck_body(<result of this func>). Could you try that instead and see if that works?
|
For context: I recently had a conversation with @fmease, and they mentioned they're planning to refactor or revise this part of the code, which they had approved in the review. So, I think we should wait for their input on this matter |
|
@camelid, |
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.
Please move this test to tests/rustdoc/jump-to-def/
In general, we currently can't obtain the resolution ( It's been a while since I looked at this part of the code but yeah for now it's okay to ignore TypeRelative QPaths "in ItemCtxts" … which this PR + other parts of the code kinda do but I'm certain it can be expressed a lot more robustly and nicely. Also CC this beautiful table I've created: #135771 (comment). |
Ah, right, I forgot about this annoyance.... Do you know what we currently do to resolve QPaths in the rest of rustdoc (not jump-to-def)? E.g. when rendering types that are trait assoc items etc. |
For cases like
hir_enclosing_body_owner()in rustdoc consideredfn foo()to be the “enclosing body” ofE, which caused to to produceHirIds forEwith owner set tofn foo()instead of the impl. This instead treatsEas having no enclosing body.r? @GuillaumeGomez as the author of this logic, I’m not 100% I understood it correctly.
Fixes #147882.
Fixes #147057.