Skip to content

Commit 5de55d8

Browse files
Add possibility to match on both full target and components
1 parent cfc656c commit 5de55d8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

text/0000-cfg-target.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- Feature Name: `cfg-target`
22
- Start Date: 2020-09-27
3-
- RFC PR: [rust-lang/rfcs#2991](https://github.com/rust-lang/rfcs/pull/2991)
3+
- RFC PR: [rust-lang/rfcs#3239](https://github.com/rust-lang/rfcs/pull/3239)
44
- Rust Issue: [rust-lang/rust#0000](https://github.com/rust-lang/rust/issues/0000)
55

66
# Summary
@@ -19,9 +19,10 @@ increases compile time and makes a crate incompatible with certain build
1919
systems.
2020

2121
Otherwise, all available components would need to be specified separately:
22-
`target_arch`, `target_vendor`, `target_os`, and `target_env`. This can be very
23-
cumbersome. Note that the target ABI cannot currently be `#[cfg]`-ed against, so
24-
a `build.rs` is still necessary to match all target components.
22+
`target_arch`, `target_vendor`, `target_os`, `target_env` and `target_abi`.
23+
This can be very cumbersome. Note that the target ABI cannot currently be
24+
`#[cfg]`-ed against, so a `build.rs` is still necessary to match all target
25+
components.
2526

2627
# Guide-level explanation
2728
[guide-level-explanation]: #guide-level-explanation
@@ -36,6 +37,16 @@ mod mac_catalyst;
3637

3738
This includes `#[cfg_attr(target = "...", attr)]`.
3839

40+
It would also support to specify each `target_*` inside a new `target`
41+
attribute as follows:
42+
43+
```rust
44+
// So we can for example rewrite:
45+
#[cfg(all(target_os = "linux", target_arch = "arm"))]
46+
// as:
47+
#[cfg(target(os = "linux", arch = "arm"))]
48+
```
49+
3950
# Reference-level explanation
4051
[reference-level-explanation]: #reference-level-explanation
4152

0 commit comments

Comments
 (0)