rust/compiler
bors ce20e15f01 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
2024-08-07 17:32:16 +00:00
..
rustc The rustc crate feature is called jemalloc 2024-07-15 13:01:20 -04:00
rustc_abi interpret: simplify pointer arithmetic logic 2024-08-01 14:25:19 +02:00
rustc_arena Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ast_ir Use dep: for crate dependencies 2024-07-15 12:40:10 -04:00
rustc_ast_lowering minor effects cleanups 2024-07-31 03:29:10 +00:00
rustc_ast_passes Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors 2024-08-03 20:51:51 +02:00
rustc_ast_pretty Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_attr Rollup merge of #128341 - Alexendoo:parse-version-pub, r=compiler-errors 2024-07-29 17:46:44 +02:00
rustc_baked_icu_data
rustc_borrowck Don't arbitrarily choose one upper bound for hidden captured region 2024-08-06 15:43:41 -04:00
rustc_builtin_macros Make Span optional in BufferedEarlyLint 2024-08-07 14:08:34 +02:00
rustc_codegen_cranelift Move computation of decorated names out of the create_dll_import_lib method 2024-07-30 10:32:32 +00:00
rustc_codegen_gcc Move computation of decorated names out of the create_dll_import_lib method 2024-07-30 10:32:32 +00:00
rustc_codegen_llvm Rollup merge of #128206 - bjorn3:import_lib_writing_refactor, r=jieyouxu 2024-08-07 15:59:35 +02:00
rustc_codegen_ssa Rollup merge of #128206 - bjorn3:import_lib_writing_refactor, r=jieyouxu 2024-08-07 15:59:35 +02:00
rustc_const_eval Auto merge of #128761 - matthiaskrgr:rollup-5p1mlqq, r=matthiaskrgr 2024-08-07 00:46:06 +00:00
rustc_data_structures Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 2024-07-30 17:49:08 +00:00
rustc_driver
rustc_driver_impl Make RUSTC_OVERRIDE_VERSION_STRING overwrite the rendered version output, too 2024-07-30 14:08:02 +00:00
rustc_error_codes Stabilize offset_of_nested 2024-07-29 17:50:12 +01:00
rustc_error_messages Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_errors fix test 2024-08-06 19:09:52 +00:00
rustc_expand Add toggle for parse_meta_item unsafe parsing 2024-07-30 18:28:43 -05:00
rustc_feature Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=compiler-errors 2024-08-05 05:40:19 +02:00
rustc_fluent_macro Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_fs_util Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_graphviz Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir Rollup merge of #128377 - veera-sivarajan:fix-128249, r=davidtwco 2024-08-06 20:23:39 +02:00
rustc_hir_analysis Rollup merge of #128424 - fee1-dead-contrib:fx-clean, r=oli-obk 2024-08-07 15:59:35 +02:00
rustc_hir_pretty Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_hir_typeck Auto merge of #125558 - Amanieu:const-asm-type, r=lcnr 2024-08-06 01:20:43 +00:00
rustc_incremental Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_index Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_index_macros Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
rustc_infer Use Vec in instantiate_binder_with_fresh_vars 2024-07-29 14:38:33 +03:00
rustc_interface Auto merge of #127543 - carbotaniuman:more_unsafe_attr_verification, r=estebank,traviscross 2024-08-01 10:40:45 +00:00
rustc_lexer Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_lint Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
rustc_lint_defs Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
rustc_llvm Disable MC/DC tests on LLVM 19 2024-07-30 10:22:48 +02:00
rustc_log Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_metadata Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_middle Auto merge of #128441 - Bryanskiy:delegation-perf, r=petrochenkov 2024-08-03 23:45:22 +00:00
rustc_mir_build custom MIR: add support for tail calls 2024-08-05 18:23:14 +02:00
rustc_mir_dataflow Stop using MoveDataParamEnv for places that don't need a param-env 2024-07-29 11:59:47 -04:00
rustc_mir_transform Re-enable SimplifyToExp in match_branches. 2024-08-03 10:55:46 +08:00
rustc_monomorphize MIR required_consts, mentioned_items: ensure we do not forget to fill these lists 2024-08-01 15:49:25 +02:00
rustc_next_trait_solver Elaborate supertraits in dyn candidates 2024-08-05 10:03:17 -04:00
rustc_parse Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors 2024-08-03 20:51:51 +02:00
rustc_parse_format Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_passes check_attr: treat cfg_attr like cfg 2024-08-06 06:12:10 +00:00
rustc_pattern_analysis Use a separate pattern type for rustc_pattern_analysis diagnostics 2024-07-31 16:03:27 +10:00
rustc_privacy Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_impl Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_query_system chore: use shorthand initializer 2024-08-02 13:22:28 -04:00
rustc_resolve docs(resolve): more explain about target 2024-08-04 15:38:11 +08:00
rustc_sanitizers Use ParamEnv::reveal_all in CFI 2024-08-02 23:24:50 -04:00
rustc_serialize Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_session Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
rustc_smir Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_span Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu 2024-08-07 00:34:11 +02:00
rustc_symbol_mangling Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_target Rollup merge of #122049 - Amanieu:riscv64-musl-tier2, r=Mark-Simulacrum 2024-08-05 23:35:22 +02:00
rustc_trait_selection Rollup merge of #128527 - estebank:ambiguity-suggestion, r=Nadrieril 2024-08-07 15:59:36 +02:00
rustc_traits Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_transmute Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_ty_utils Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 2024-07-30 17:49:08 +00:00
rustc_type_ir Auto merge of #128689 - matthiaskrgr:rollup-ukyn8wq, r=matthiaskrgr 2024-08-05 17:03:58 +00:00
rustc_type_ir_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
stable_mir Reformat use declarations. 2024-07-29 08:26:52 +10:00