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 but I might be wrong and it might also require special closure logic when resolving fn ptrs inrust/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.
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.