Implement Debug, Pointer, etc on function pointers for all calling conventions#92964
Implement Debug, Pointer, etc on function pointers for all calling conventions#92964Kampfkarren wants to merge 6 commits intorust-lang:masterfrom
Conversation
|
r? @yaahc (rust-highfive has picked a reviewer for you, use r? to override) |
|
@rustbot author |
|
Going to be completely out next week--will try to finish up reviews the week after, apologies. |
|
Will finish tomorrow, promise, apologies |
|
CC @yaahc |
|
@rustbot ready |
|
r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs |
dtolnay
left a comment
There was a problem hiding this comment.
The changes look good so far, but I don't think this can be merged as currently implemented without further work in rustdoc. This PR changes doc/core/primitive.fn.html from 1.4 MB to 14 MB which is beyond what is reasonable and getting into crashy territory for browsers.
@Kampfkarren could you please look into making rustdoc render all these repetitive impls in some more compact way?
|
This overlaps with #96513. |
Another potential concern is the size of the rlib. How much bugger does compiled libcore become through all these extra instances? |
|
As an alternative solution we could (and should imo) add a builtin trait: trait FnPtr {
// Alternatively `-> usize` idc
fn as_ptr(self) -> *const ();
// Other additions, like `const VARIADIC: bool` or whatever can be added if needed
}This trait can then be used to implement |
If this is done via a blanket |
|
the coherence implications should fall out directly from the compiler internal impl of |
On my machine, comparing 764b861...8efec95, this PR increases the size of libcore.rlib from 57834522 bytes to 71612866 bytes, or 23.8%. |
|
Hm. Any way around that? |
|
Yes, it was proposed here 15 days ago. That will help a lot. But as others noted above it might need some new trait system trickery. Even better would be to make |
|
☔ The latest upstream changes (presumably #98180) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I don't think I have the time to make a more closer to the compiler change like an FnPtr trait right now (and it feels like I'd want to have an RFC for that anyway) |
|
FWIW a |
|
Related:
|
…pls, r=thomcc Add default trait implementations for "c-unwind" ABI function pointers Following up on rust-lang#92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in rust-lang#92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib. An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in rust-lang#99531 but this change looks to be blocked on a lang MCP. Following `@RalfJung's` suggestion in rust-lang#99531 (comment), this commit is another cut at rust-lang#92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`. I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature. RFC: rust-lang/rfcs#2945 Tracking Issue: rust-lang#74990
Extends the default function pointer implementations, such as Debug, to all stable calling conventions.
I would like to extend this to the unstable calling conventions as well, but cannot find a way to do so that appeases ineffective_unstable_trait_impl.