os-rust/compiler/rustc_ast_pretty/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
..
pp Pretty print ItemKind::Use in rustfmt style 2022-02-07 21:51:05 -08:00
pprust Split MacArgs in two. 2022-11-22 09:04:15 +11:00
helpers.rs Delete duplicated helpers from HIR printer 2021-12-05 12:45:51 -08:00
lib.rs Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
pp.rs fix most compiler/ doctests 2022-05-02 17:40:30 -07:00