Description
Proposal
Implement what was proposed 5 years ago in rust-lang/rust#63585
Add a new way to implement intrinsics that does not require us to abuse the fake rust-intrinsic
ABI.
The new scheme allows using regular functions, and turning them into intrinsics by adding the #[rustc_intrinsic]
attribute to them. The body of the function is used on backends that have not implemented the intrinsic. This avoids us having to write backend code to generate the function body.
For some intrinsics having a fallback body makes no sense, as there is either no reasonable default or it's something absolutely compiler internal (e.g. size_of
). In that case, one can add another #[rustc_intrinsic_must_be_overridden]
to the function. This causes the function body to not get monomorphized and sent to the backend. The implementation has various assertions that prevent screwing this up. So if a backend forgets to implement, at best they get an assertion explaining what's going on, at worst they get a linker error.
Once this is accepted and the implementation has landed, we can incrementally eliminate all those intrinsics and then remove support from the compiler for the rust-intrinsic
ABI. Similarly we'll eliminate the platform-intrinsic
ABI.
Already implemented in rust-lang/rust#120500 and rust-lang/rust#120675
Mentors or Reviewers
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member or contributor who is knowledgeable in the area can second by writing
@rustbot second
.- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
-C flag
, then full team check-off is required. - Compiler team members can initiate a check-off via
@rfcbot fcp merge
on either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
- Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.