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#:
- the
asm!/global_asm! macros
- there is a PRs open for
format_args
- another PR is open for
offset_of
- An eventual replacement for
box syntax that is more of an implementation detail than a future feature at this point. It is still used in the vec macro thus can't be removed easily. This would free up box as a keyword.
- Any future language feature whose syntax is not decided yet but people want to experiment with it. E.g.
do yeet comes to mind.
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.
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. Soasm!(foo)becomesbuiltin#asm(foo).Possible cases of
builtin#:asm!/global_asm!macrosformat_argsoffset_ofboxsyntax that is more of an implementation detail than a future feature at this point. It is still used in thevecmacro thus can't be removed easily. This would free upboxas a keyword.do yeetcomes to mind.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_rulesmacros with anallow_internal_unstable(or alternativelymacromacros).Mentors or Reviewers
@petrochenkov has expressed desire for this.
Process
The main points of the Major Change Process are as follows:
@rustbot second.-C flag, then full team check-off is required.@rfcbot fcp mergeon either the MCP or the PR.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.