summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/assert.rs
AgeCommit message (Collapse)AuthorLines
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-5/+5
`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-08-17Box the `MacCall` in various types.Nicholas Nethercote-2/+2
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-2/+2
2022-06-02Basic compiler infraCaio-22/+48
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-6/+2
2022-01-31Fix invalid special casing of the unreachable! macroLoïc BRANSTETT-1/+1
2021-10-07Use correct edition for panic in [debug_]assert!() etc.Mara Bos-3/+3
2021-02-01Fix bug with assert!() calling the wrong edition of panic!().Mara Bos-2/+2
The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version.
2021-01-24Only call span.rust_2021() when necessary.Mara Bos-7/+5
2021-01-09Expand assert!(expr, args..) to include $crate for hygiene on 2021.Mara Bos-1/+19
Before 2021, this was a breaking change, as std::panic and core::panic are different. In edition 2021 they will be identical, making it possible again to apply proper hygiene here.
2020-10-19Small cleanups in assert!() and panic_fmt lint.Mara Bos-31/+29
(From the PR feedback.) Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-10-18Expand assert!(expr) to panic() function instead of panic!() macro.Mara Bos-26/+36
The panic message might contain braces which should never be interpreted as format placeholders, which panic!() will do in a future edition.
2020-10-06rustc_parse: Make `Parser::unexpected` public and use it in built-in macrosVadim Petrochenkov-2/+1
2020-08-30mv compiler to compiler/mark-0/+133