Implement Fn traits for safe functions of any ABI - #160186
Jules-Bertholet wants to merge 1 commit into
Conversation
|
cc @rust-lang/miri |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Don't you need to generate shims or Happy Things will happen? |
|
I don't think so? The basic tests I added work fine, and Miri doesn't complain. But I don't really know that part of the codebase, am relying on Cunningham's Law |
|
I suggest you check with |
|
Nothing broke… |
|
🤷 Maybe it is fine... |
|
Although the practical ABI for |
|
Probably should make sure the function that calls the |
|
Yeah I'd expect the rust-call / argument (un)tupling to go wrong here as that needs the Rust ABI. Does this actually solve a problem? If not I'd rather update the docs. |
32a4f77 to
2403142
Compare
|
Modified the tests to use a function that I confirmed with Godbolt has a completely different |
With new ABIs like |
|
I guess what happens is that we synthesize a But someone should dig into where that happens. |
|
|
||
| pub fn is_fn_trait_compatible(self) -> bool { | ||
| !self.c_variadic() && self.safety().is_safe() && self.abi() == ExternAbi::Rust | ||
| !self.c_variadic() && self.safety().is_safe() && self.abi().is_fn_trait_compatible() |
There was a problem hiding this comment.
| !self.c_variadic() && self.safety().is_safe() && self.abi().is_fn_trait_compatible() | |
| self.safety().is_safe() && self.abi().is_fn_trait_compatible() |
We could try to remove the !self.c_variadic() condition. But there's not much point, as any actual use of variadics is necessarily unsafe. It would also be a bunch of work, as the trait solver currently assumes no type has more than one impl of each Fn trait.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
9833f5d to
81bebb9
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This brings the behavior of the language in line with the documentation in `library/core/src/primitive_docs.rs`.
81bebb9 to
d9d97c4
Compare
View all comments
This brings the behavior of the language in line with its documentation:
rust/library/core/src/primitive_docs.rs
Lines 1930 to 1931 in 1a833e1
ABIs that are not callable, or that are internal implementation details, are excluded.
@rustbot label T-lang needs-fcp A-ABI A-extern-fn I-lang-nominated