Jonathan Brouwer
b9f8e25f6e
Rollup merge of #146961 - Jules-Bertholet:expr-cfg, r=JonathanBrouwer
...
Allow passing `expr` metavariable as `cfg` predicate
This PR allows expanding `expr` metavariables inside the configuration predicates of `cfg` and `cfg_attr` invocations.
For example, the following code will now compile:
```rust
macro_rules! mac {
($e:expr) => {
#[cfg_attr($e, inline)]
#[cfg($e)]
fn func() {}
#[cfg(not($e))]
fn func() {
panic!()
}
}
}
mac!(any(unix, feature = "foo"));
```
There is currently no `macro_rules` fragment specifier that can represent all valid `cfg` predicates. `meta` comes closest, but excludes `true` and `false`. By fixing that, this change makes it easier to write declarative macros that parse `cfg` or `cfg_attr` invocations, for example https://github.com/rust-lang/rust/pull/146281/ .
@rustbot label T-lang needs-fcp A-attributes A-cfg A-macros
2026-03-21 00:42:47 +01:00
..
2025-11-28 13:12:15 +09:00
2025-12-18 15:53:39 +00:00
2026-02-08 17:02:40 +01:00
2026-03-04 08:06:45 +08:00
2025-11-27 14:13:58 -05:00
2026-02-11 14:13:44 +01:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2026-01-26 17:34:31 +00:00
2026-01-26 17:34:31 +00:00
2026-03-20 18:48:38 -04:00
2026-03-20 18:48:38 -04:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-03-15 13:44:14 -04:00
2026-03-15 13:44:14 -04:00
2026-02-22 19:59:25 +01:00
2026-02-22 19:59:25 +01:00
2026-03-15 13:44:14 -04:00
2026-02-22 19:59:25 +01:00
2026-02-22 19:59:25 +01:00
2026-03-15 13:44:14 -04:00
2025-12-06 10:22:13 +01:00
2025-12-06 10:22:13 +01:00
2026-01-16 06:50:34 +09:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2025-12-18 15:53:39 +00:00
2026-03-16 10:21:35 +00:00
2026-03-16 10:21:35 +00:00
2026-03-09 09:11:06 +00:00
2026-03-09 09:11:06 +00:00
2025-12-10 15:15:56 +01:00
2026-01-26 17:34:31 +00:00
2026-02-18 18:33:35 +00:00
2026-01-26 17:34:31 +00:00
2026-02-18 18:33:35 +00:00
2026-02-12 17:43:58 +00:00
2026-03-17 10:07:52 +00:00
2026-03-17 10:07:52 +00:00
2026-02-25 17:20:18 +01:00
2025-12-10 23:41:19 +00:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-12-03 16:38:24 +01:00
2025-12-03 16:38:24 +01:00
2026-02-12 15:30:41 +08:00
2026-02-12 15:30:41 +08:00
2026-02-12 15:30:41 +08:00
2026-03-03 21:57:02 +01:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2025-12-09 17:29:23 +00:00
2025-11-28 13:12:15 +09:00
2025-11-28 13:12:15 +09:00
2025-11-28 13:12:15 +09:00
2025-11-27 14:13:58 -05:00
2025-11-27 11:19:00 -05:00
2025-12-09 17:29:23 +00:00
2026-01-26 17:34:31 +00:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-12-04 14:58:46 +08:00
2025-12-04 14:58:46 +08:00
2026-03-03 21:57:02 +01:00
2026-03-17 18:24:54 -04:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2026-02-17 08:45:08 +00:00
2026-01-26 17:34:31 +00:00
2025-12-09 17:29:23 +00:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 14:13:58 -05:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2025-12-09 17:29:23 +00:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-12-09 17:29:23 +00:00
2026-01-30 21:32:37 +03:00
2026-01-30 21:32:37 +03:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2026-03-09 09:11:06 +00:00
2026-03-09 09:11:06 +00:00
2026-02-17 16:51:44 +00:00
2026-02-17 16:51:44 +00:00
2026-03-04 08:06:45 +08:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2026-03-05 12:12:31 +01:00
2026-02-17 08:45:08 +00:00
2026-03-04 19:30:36 +01:00
2025-12-03 17:01:49 +01:00
2025-12-03 17:01:49 +01:00
2026-02-01 13:16:32 +00:00
2026-02-01 13:16:32 +00:00
2026-02-18 20:14:36 +05:30
2026-02-18 20:14:36 +05:30
2026-02-18 20:14:36 +05:30
2026-02-18 20:14:36 +05:30
2026-02-18 20:14:36 +05:30
2025-12-16 02:10:08 +09:00
2025-12-16 02:10:08 +09:00
2026-03-16 10:21:35 +00:00
2026-02-16 17:27:40 +01:00
2026-02-16 17:27:40 +01:00
2026-02-11 20:37:45 -05:00
2026-02-11 20:37:45 -05:00