-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Support #[track_caller]
on closures.
#74492
Conversation
r? @lcnr (rust_highfive has picked a reviewer for you, use r? to override) |
Fails locally with:
|
afaik closures use This calling convention takes the argument list and wraps them in a tuple to support generics. |
Thanks! That jogged my memory for the portion of codegen to look at. Since the assertion is there to prevent miscompilation I tried commenting it out and the argument passing appeared to "just work". Will still need to figure out the right number to assert on in the presence of untupled args but that can be done later. The next issue is that the "definition span" we get for a closure-as-fn-ptr appears to be in libcore:
I think this will need to be modified in
rust/src/librustc_middle/ty/instance.rs Line 375 in 2666aed
cc @eddyb btw |
Sounds like you need to make some of the You might be able to get away with testing a case where a closure doesn't implement more than Then again, you mention coercing to a |
// fn_abi.args.len(), | ||
// args.len() + 1, | ||
// "#[track_caller] fn's must have 1 more argument in their ABI than in their MIR", | ||
// ); |
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.
If the abi is "Rust-call" then the argument count is 1 (for the self argument) + the amount of elements in the type of the second argument (the operands bundle, which is a tuple).
@anp any updates? |
☔ The latest upstream changes (presumably #74932) made this pull request unmergeable. Please resolve the merge conflicts. |
@anp thanks for taking the time to contribute. Sadly this PR is inactive so I'm going to close it. If you wish and you have the time to complete this, you can open a new pull request and we'll take it from there. |
Closes #74042.