Add builtin# for compiler-intrinsic syntax (original) (raw)

Proposal

Some of rust's builtin macros use their direct access to the AST to do things that proc macros can't: create AST nodes that are not present in syntax. This turns those macros into language extensions more than actual macros.

The proposed solution is to add the builtin#... syntax intended for constructs that are perma-unstable, possibly having stable wrappers, where no final syntax is known.

builtin# would always be followed by a conditional keyword that corresponds to the functionality of the construct, and then contain its arguments in parentheses. So asm!(foo) becomes builtin#asm(foo).

Possible cases of builtin#:

Acceptance of this MCP does not imply that all of these should be migrated. For the last few non-macro cases the migration discussion is explicitly left for the future. Mainly, the list serves to show the targeted area of builtin#.

Macros can be changed to macro_rules macros with an allow_internal_unstable (or alternatively macro macros).

Mentors or Reviewers

@petrochenkov has expressed desire for this.

Process

The main points of the Major Change Process are as follows:

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.