rust/compiler/rustc_builtin_macros/src
Dylan DPC 9c310571a8
Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011
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
2021-03-08 13:13:23 +01:00
..
deriving Borrow builder only once in debug derive 2021-02-10 00:00:00 +00:00
format_foreign mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
asm.rs rustc_parse: Make Parser::unexpected public and use it in built-in macros 2020-10-06 00:23:36 +03:00
assert.rs Fix bug with assert!() calling the wrong edition of panic!(). 2021-02-01 23:23:27 +01:00
cfg_accessible.rs expand: Tell built-in macros whether we are currently in forced expansion mode 2020-11-19 19:25:20 +03:00
cfg_eval.rs rustc_builtin_macros: Share some more logic between derive and cfg_eval 2021-03-07 01:12:18 +03:00
cfg.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
cmdline_attrs.rs Unconditionally capture tokens for attributes. 2020-10-21 18:57:29 -04:00
compile_error.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
concat_idents.rs expand: Stop un-interpolating NtIdents before passing them to built-in macros 2020-09-28 23:10:44 +03:00
concat.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
derive.rs rustc_builtin_macros: Share some more logic between derive and cfg_eval 2021-03-07 01:12:18 +03:00
env.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
format_foreign.rs avoid full-slicing slices 2021-02-16 00:31:11 +01:00
format.rs avoid full-slicing slices 2021-02-16 00:31:11 +01:00
global_allocator.rs Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
global_asm.rs Remove some P-s 2021-02-20 10:51:26 +01:00
lib.rs Implement built-in attribute macro #[cfg_eval] 2021-03-06 23:03:19 +03:00
llvm_asm.rs Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkov 2020-12-30 20:56:58 +00:00
log_syntax.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
panic.rs Implement new panic!() behaviour for Rust 2021. 2021-01-25 13:48:11 +01:00
proc_macro_harness.rs ast: Stop using Mod in Crate 2021-02-18 13:07:49 +03:00
source_util.rs expand: Some more consistent naming in module loading 2021-03-05 01:33:43 +03:00
standard_library_imports.rs Remove some P-s 2021-02-20 10:51:26 +01:00
test_harness.rs ast: Keep expansion status for out-of-line module items 2021-02-18 13:07:49 +03:00
test.rs Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
trace_macros.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
util.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00