mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-07 15:37:39 +00:00
![]() Implement built-in attribute macro `#[cfg_eval]` + some refactoring This PR implements a built-in attribute macro `#[cfg_eval]` as it was suggested in https://github.com/rust-lang/rust/pull/79078 to avoid `#[derive()]` without arguments being abused as a way to configure input for other attributes. The macro is used for eagerly expanding all `#[cfg]` and `#[cfg_attr]` attributes in its input ("fully configuring" the input). The effect is identical to effect of `#[derive(Foo, Bar)]` which also fully configures its input before passing it to macros `Foo` and `Bar`, but unlike `#[derive]` `#[cfg_eval]` can be applied to any syntax nodes supporting macro attributes, not only certain items. `cfg_eval` was the first name suggested in https://github.com/rust-lang/rust/pull/79078, but other alternatives are also possible, e.g. `cfg_expand`. ```rust #[cfg_eval] #[my_attr] // Receives `struct S {}` as input, the field is configured away by `#[cfg_eval]` struct S { #[cfg(FALSE)] field: u8, } ``` Tracking issue: https://github.com/rust-lang/rust/issues/82679 |
||
---|---|---|
.. | ||
deriving | ||
format_foreign | ||
asm.rs | ||
assert.rs | ||
cfg_accessible.rs | ||
cfg_eval.rs | ||
cfg.rs | ||
cmdline_attrs.rs | ||
compile_error.rs | ||
concat_idents.rs | ||
concat.rs | ||
derive.rs | ||
env.rs | ||
format_foreign.rs | ||
format.rs | ||
global_allocator.rs | ||
global_asm.rs | ||
lib.rs | ||
llvm_asm.rs | ||
log_syntax.rs | ||
panic.rs | ||
proc_macro_harness.rs | ||
source_util.rs | ||
standard_library_imports.rs | ||
test_harness.rs | ||
test.rs | ||
trace_macros.rs | ||
util.rs |