diff options
| author | bors <bors@rust-lang.org> | 2024-08-07 17:32:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-07 17:32:16 +0000 |
| commit | ce20e15f01a9dcc4543e8d52b4b281df6c4dbb8e (patch) | |
| tree | 24772ddefecdbaa62e3c84c31b984c35d5b7e6de /compiler/rustc_interface/src/tests.rs | |
| parent | 8d0066922b14cee3175e8c141e5e909fa6d9a6eb (diff) | |
| parent | c0c57b3e2953241124810a59faf77d50e91b3e01 (diff) | |
| download | rust-ce20e15f01a9dcc4543e8d52b4b281df6c4dbb8e.tar.gz rust-ce20e15f01a9dcc4543e8d52b4b281df6c4dbb8e.zip | |
Auto merge of #126158 - Urgau:disallow-cfgs, r=petrochenkov
Disallow setting some built-in cfg via set the command-line
This PR disallow users from setting some built-in cfg via set the command-line in order to prevent incoherent state, eg. `windows` cfg active but target is Linux based.
This implements MCP https://github.com/rust-lang/compiler-team/issues/610, with the caveat that we disallow cfgs no matter if they make sense or not, since I don't think it's useful to allow users to set a cfg that will be set anyway. It also complicates the implementation.
------
The `explicit_builtin_cfgs_in_flags` lint detects builtin cfgs set via the `--cfg` flag.
*(deny-by-default)*
### Example
```text
rustc --cfg unix
```
```rust,ignore (needs command line option)
fn main() {}
```
This will produce:
```text
error: unexpected `--cfg unix` flag
|
= note: config `unix` is only supposed to be controlled by `--target`
= note: manually setting a built-in cfg can and does create incoherent behaviours
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
```
### Explanation
Setting builtin cfgs can and does produce incoherent behaviour, it's better to the use the appropriate `rustc` flag that controls the config. For example setting the `windows` cfg but on Linux based target.
-----
r? `@petrochenkov`
cc `@jyn514`
try-job: aarch64-apple
try-job: test-various
try-job: armhf-gnu
try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-gnu-llvm-17
try-job: dist-various-1
Diffstat (limited to 'compiler/rustc_interface/src/tests.rs')
0 files changed, 0 insertions, 0 deletions
