-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-nominatedNominated for discussion during a lang team meeting.Nominated for discussion during a lang team meeting.S-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(fn_static)]
This is a tracking issue for FnStatic and FnPtr::addr/from_ptr/as_ptr and Code.
Public API
// core::ops
pub extern type Code;
// Implemented only for function pointers.
pub unsafe trait FnPtr {
fn addr(self) -> usize;
fn as_ptr(self) -> NonNull<Code>;
unsafe fn from_ptr(NonNull<Code>) -> Self;
}
// Implemented for all types that coerce to function pointers.
pub unsafe trait FnStatic<Args>: Fn<Args> {
type FnPtr: FnPtr;
fn as_fn() -> Self::FnPtr;
fn addr() -> usize;
fn as_ptr() -> NonNull<Code>;
extern "rust-call" fn call_static(args: Args) -> Self::Output;
}Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP: API for explicitly getting an opaque pointer of a function libs-team#589
- t-lang approval because
FnStaticis a new builtin trait that interacts with the language, as well as discussing how to deal with new targets where code pointers are bigger than data pointers. - Implementation: #...
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Is it sufficient to just add type aliases whenever adding a target where code pointers are bigger than data pointers? It was proposed that
NonNull<Code>is used for pointing to the code of a function, and that whenever a target where code pointers are larger than data pointers is added, then type aliases are added and APIs are changed to use those type aliases instead of directly usingNonNull<Code>orusizewhen representing code addresses.
Footnotes
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-nominatedNominated for discussion during a lang team meeting.Nominated for discussion during a lang team meeting.S-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.