rust/compiler
Josh Triplett 6c04e0a7ae Rewrite macro_rules! parser to not use the MBE engine itself
The `macro_rules!` parser was written to match the series of rules using
the macros-by-example (MBE) engine and a hand-written equivalent of the
left-hand side of a MBE macro. This was complex to read, difficult to
extend, and produced confusing error messages. Because it was using the
MBE engine, any parse failure would be reported as if some macro was
being applied to the `macro_rules!` invocation itself; for instance,
errors would talk about "macro invocation", "macro arguments", and
"macro call", when they were actually about the macro *definition*.

And in practice, the `macro_rules!` parser only used the MBE engine to
extract the left-hand side and right-hand side of each rule as a token
tree, and then parsed the rest using a separate parser.

Rewrite it to parse the series of rules using a simple loop, instead.
This makes it more extensible in the future, and improves error
messages. For instance, omitting a semicolon between rules will result
in "expected `;`" and "unexpected token", rather than the confusing "no
rules expected this token in macro call".

This work was greatly aided by pair programming with Vincenzo Palazzo
and Eric Holk.
2025-06-26 15:20:42 -07:00
..
rustc Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_abi compiler: Trim the misleading C from ExternAbi::CCmse* 2025-06-25 00:52:09 -07:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast Auto merge of #142997 - workingjubilee:rollup-6lxec87, r=workingjubilee 2025-06-25 04:05:47 +00:00
rustc_ast_ir Use -Wunused_crate_dependencies for compiler crates. 2025-03-20 08:59:43 +11:00
rustc_ast_lowering compiler: remove misleading 'c' from abi_c_cmse_nonsecure_call feature 2025-06-25 00:52:10 -07:00
rustc_ast_passes Error on invalid signatures for interrupt ABIs 2025-06-24 14:40:11 +02:00
rustc_ast_pretty Rollup merge of #135731 - frank-king:feature/pin-borrow, r=eholk,traviscross 2025-06-24 19:45:29 -07:00
rustc_attr_data_structures encode_cross_crate for hir attributes 2025-06-25 22:10:40 +02:00
rustc_attr_parsing Rollup merge of #142825 - jdonszelmann:track-caller, r=oli-obk 2025-06-24 19:45:32 -07:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_builtin_macros Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_codegen_cranelift Rollup merge of #142955 - bjorn3:cg_clif_test_fixes, r=jieyouxu 2025-06-24 19:45:34 -07:00
rustc_codegen_gcc Remove dead instructions in terminate blocks 2025-06-22 11:38:47 -04:00
rustc_codegen_llvm Auto merge of #143026 - jdonszelmann:rollup-z7mkuyt, r=jdonszelmann 2025-06-25 23:33:23 +00:00
rustc_codegen_ssa Auto merge of #142879 - Mark-Simulacrum:opt-cleanup, r=WaffleLapkin 2025-06-25 17:33:39 +00:00
rustc_const_eval Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_data_structures Rollup merge of #142868 - klensy:dc, r=oli-obk 2025-06-22 17:35:36 +02:00
rustc_driver Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
rustc_driver_impl rustc_session: Add a structure for keeping both explicit and default sysroots 2025-06-24 16:00:04 +03:00
rustc_error_codes compiler: Trim the misleading C of C-cmse from errors 2025-06-25 00:52:10 -07:00
rustc_error_messages rustc_session: Add a structure for keeping both explicit and default sysroots 2025-06-24 16:00:04 +03:00
rustc_errors Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_expand Rewrite macro_rules! parser to not use the MBE engine itself 2025-06-26 15:20:42 -07:00
rustc_feature Auto merge of #143026 - jdonszelmann:rollup-z7mkuyt, r=jdonszelmann 2025-06-25 23:33:23 +00:00
rustc_fluent_macro Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
rustc_fs_util Retry if creating temp fails with access denied 2025-04-25 11:28:36 +00:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir All HIR attributes are outer 2025-06-21 11:11:34 -07:00
rustc_hir_analysis Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_hir_pretty Rollup merge of #135731 - frank-king:feature/pin-borrow, r=eholk,traviscross 2025-06-24 19:45:29 -07:00
rustc_hir_typeck Rollup merge of #142976 - compiler-errors:coerce-ice, r=fee1-dead 2025-06-25 22:14:56 +02:00
rustc_incremental Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk 2025-05-07 12:39:54 +00:00
rustc_index index: add method for checking range on DenseBitSet 2025-06-04 00:47:12 +02:00
rustc_index_macros In rustc_mir_tranform, iterate over index newtypes instead of ints 2025-04-12 11:53:07 +00:00
rustc_infer Cache instantiation of canonical binder 2025-06-19 04:23:25 +00:00
rustc_interface Rollup merge of #142934 - nnethercote:tweak-macro-stats, r=petrochenkov 2025-06-24 19:45:33 -07:00
rustc_lexer rustc_lexer: typo fix + small cleanups 2025-06-06 13:08:16 +00:00
rustc_lint Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_lint_defs compiler: Remove unsupported_fn_ptr_calling_conventions lint 2025-06-23 09:39:59 -07:00
rustc_llvm rustc_llvm: add Windows system libs only when cross-compiling from Windows 2025-05-31 15:47:14 +02:00
rustc_log Add documentation for init_logger_with_additional_layer 2025-06-12 12:11:15 +02:00
rustc_macros Add runtime check to avoid overwrite arg easily in diag and store and restore snapshot when set subdiag arg 2025-06-25 21:07:16 +08:00
rustc_metadata Auto merge of #143026 - jdonszelmann:rollup-z7mkuyt, r=jdonszelmann 2025-06-25 23:33:23 +00:00
rustc_middle Rollup merge of #142146 - workingjubilee:doubt-that-cmse-nonsecure-abis-always-match-c, r=compiler-errors 2025-06-25 22:14:54 +02:00
rustc_mir_build Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_mir_dataflow update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
rustc_mir_transform Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_monomorphize Skip collecting no-op DropGlue in vtables 2025-06-21 18:59:36 -04:00
rustc_next_trait_solver Auto merge of #142774 - lcnr:search_graph-2, r=oli-obk 2025-06-26 17:04:47 +00:00
rustc_parse Auto merge of #142997 - workingjubilee:rollup-6lxec87, r=workingjubilee 2025-06-25 04:05:47 +00:00
rustc_parse_format update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
rustc_passes Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_pattern_analysis Add #[loop_match] for improved DFA codegen 2025-06-23 20:43:04 +02:00
rustc_privacy Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
rustc_proc_macro update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
rustc_query_impl Auto merge of #140145 - Zoxc:job-server-proxy, r=SparrowLii 2025-05-01 04:11:52 +00:00
rustc_query_system Rollup merge of #142384 - celinval:chores-rayon-mv, r=oli-obk 2025-06-20 23:25:54 -04:00
rustc_resolve Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk 2025-06-25 22:14:55 +02:00
rustc_sanitizers Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
rustc_serialize Add a few inline directives in rustc_serialize. 2025-06-21 23:54:16 +00:00
rustc_session Rollup merge of #142809 - KMJ-007:ad-type-analysis-flag, r=ZuseZ4 2025-06-25 22:14:55 +02:00
rustc_smir compiler: Trim the misleading C from ExternAbi::CCmse* 2025-06-25 00:52:09 -07:00
rustc_span Rewrite macro_rules! parser to not use the MBE engine itself 2025-06-26 15:20:42 -07:00
rustc_symbol_mangling Change __rust_no_alloc_shim_is_unstable to be a function 2025-06-16 10:54:07 -07:00
rustc_target Rollup merge of #142992 - workingjubilee:dont-validate-naughty-abis, r=jieyouxu 2025-06-25 22:14:56 +02:00
rustc_thread_pool Apply suggestions from code review 2025-06-16 12:27:47 -07:00
rustc_trait_selection Auto merge of #142774 - lcnr:search_graph-2, r=oli-obk 2025-06-26 17:04:47 +00:00
rustc_traits FIXME(-Znext-solver) triage 2025-06-03 14:23:56 +02:00
rustc_transmute transmutability: shift abstraction boundary 2025-06-09 14:08:12 +00:00
rustc_ty_utils Add #[loop_match] for improved DFA codegen 2025-06-23 20:43:04 +02:00
rustc_type_ir Auto merge of #142774 - lcnr:search_graph-2, r=oli-obk 2025-06-26 17:04:47 +00:00
rustc_type_ir_macros Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00
stable_mir Change rustc_driver dependency on stable_mir crate 2025-04-30 15:39:52 -07:00