rust/compiler/rustc_builtin_macros/src
Nicholas Nethercote 3e3a4192d8 Split MacArgs in two.
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's
used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all
  three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`),
  where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them
having partial overlap. I find this makes the code hard to read. It also leads
to various unreachable code paths, and allows invalid values (such as
accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is
  now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro
  case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and
disallows the invalid values.
2022-11-22 09:04:15 +11:00
..
assert Split MacArgs in two. 2022-11-22 09:04:15 +11:00
deriving Streamline deriving on packed structs. 2022-11-21 14:07:39 +11:00
format Update doc comments. 2022-09-27 13:31:52 +02:00
format_foreign update tests 2021-12-31 12:51:27 -05:00
alloc_error_handler.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
asm.rs Use token::Lit in ast::ExprKind::Lit. 2022-11-16 09:41:28 +11:00
assert.rs Split MacArgs in two. 2022-11-22 09:04:15 +11:00
cfg_accessible.rs Add the #[derive_const] attribute 2022-09-20 11:57:58 +00:00
cfg_eval.rs Workaround unstable stmt_expr_attributes for method receiver expressions. 2022-10-23 09:27:12 +00:00
cfg.rs Migrate all diagnostics 2022-10-23 10:09:44 +02:00
cmdline_attrs.rs make mk_attr_id part of ParseSess 2022-09-14 08:49:10 +08:00
compile_error.rs check_doc_keyword: don't alloc string for emptiness check 2022-04-08 11:45:57 +03:00
concat_bytes.rs Use token::Lit in ast::ExprKind::Lit. 2022-11-16 09:41:28 +11:00
concat_idents.rs Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
concat.rs Use token::Lit in ast::ExprKind::Lit. 2022-11-16 09:41:28 +11:00
derive.rs Add the #[derive_const] attribute 2022-09-20 11:57:58 +00:00
edition_panic.rs Split MacArgs in two. 2022-11-22 09:04:15 +11:00
env.rs check_doc_keyword: don't alloc string for emptiness check 2022-04-08 11:45:57 +03:00
format_foreign.rs [rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape 2021-12-31 12:42:15 -05:00
format.rs Fix format_args capture for macro expanded format strings 2022-09-30 17:40:14 +01:00
global_allocator.rs Replace rustc_data_structures::thin_vec::ThinVec with thin_vec::ThinVec. 2022-08-29 15:42:13 +10:00
lib.rs Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk 2022-11-12 12:02:50 +05:30
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
proc_macro_harness.rs Use AttrVec in more places. 2022-08-22 07:35:33 +10:00
source_util.rs Introduce ExprKind::IncludedBytes 2022-11-11 16:31:32 +00:00
standard_library_imports.rs Replace rustc_data_structures::thin_vec::ThinVec with thin_vec::ThinVec. 2022-08-29 15:42:13 +10:00
test_harness.rs Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726 2022-10-24 19:32:25 +09:00
test.rs Rollup merge of #103445 - fmease:fix-50291, r=estebank 2022-11-11 20:51:38 +05:30
trace_macros.rs Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
util.rs Add a lint for duplicated attributes. 2021-12-15 23:43:13 +01:00