-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Remove clean::Function::header and calculate it on-demand #91217
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
Remove clean::Function::header and calculate it on-demand #91217
Conversation
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.
This is awesome ❤️ Thank you for working on this!
Hmm, can you run this locally with RUST_BACKTRACE set to see how it's happening? I wonder if we need to avoid calling |
Maybe also look at |
This comment has been minimized.
This comment has been minimized.
@rustbot label -S-waiting-on-author +S-waiting-on-review |
This comment has been minimized.
This comment has been minimized.
@rustbot label +S-waiting-on-author -S-waiting-on-review |
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.
This looks mostly good from me, but I'd like to have someone from the compiler team review - @petrochenkov would you be willing to look over the HIR changes?
/// `extern "C" { pub fn foo(); }` | ||
ForeignFn(Ident), |
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.
This new variant shouldn't be necessary - if you look at ItemFn
above it allows for an ABI field.
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.
But it requires a FnHeader
, which is not available for ForeignItem
functions.
Should I just create a header with all items such as asyncness
and constness
set to false?
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.
This is a good question for petrochenkov, I'm not sure. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.ForeignItemKind.html has a FnDecl but not FnHeader. Maybe try implementing that for now and we can change it later if necessary.
The HIR changes do not look right, the new variant is not integrated into the HIR visitor ( As you can see r? @jyn514 |
@petrochenkov how can we find this information for functions without bodies without using |
The constness is always non-const for foreign functions, and the ABI can be taken from their parent item - the |
☔ The latest upstream changes (presumably #91291) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm probably missing some context, but what's wrong with using |
@camelid it panics on trait functions without a default implementation |
But don't those still have signatures? |
Ping from triage: |
@yuvaldolev @rustbot label: +S-inactive |
Just gave a try to this issue and I think this is the wrong approach. I'll open a PR shortly once I'm done with the cleanup. |
…camelid Remove header field from clean::Function Fixes rust-lang#89673. This is another take on rust-lang#89673 (compared to rust-lang#91217) but very different on the approach: I moved the header call in one place but still require to have the `clean::Item` so I can use the `DefId` to get what is missing. cc `@jyn514` (you reviewed the original so maybe you want to take a look?) r? `@camelid`
Addresses #89673
Remove
clean::Function::header
and calculate it on-demand based on theDefId
.r? @jyn514