Files
rust/library/std/src/sys
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
..
2026-01-26 10:59:16 +00:00
2026-03-03 12:26:21 +01:00
2026-03-14 17:54:19 +05:30
2026-01-02 18:32:35 +01:00
2026-03-12 15:49:13 +01:00
2026-03-04 16:56:29 +01:00
2025-10-08 08:57:58 -07:00
2026-03-14 22:09:35 -04:00
2026-02-23 13:13:27 +01:00
2026-02-23 13:13:27 +01:00