1
Fork 0
rust/compiler
Matthias Krüger ce407429dd
Rollup merge of #111072 - Urgau:check-cfg-new-syntax, r=petrochenkov
Add new simpler and more explicit syntax for check-cfg

<details>
<summary>
Old proposition (before the MCP)
</summary>

This PR adds a new simpler and more explicit syntax for check-cfg. It consist of two new form:
 - `exhaustive(names, values)`
 - `configure(name, "value1", "value2", ... "valueN")`

The preview forms `names(...)` and `values(...)` have implicit meaning that are not strait-forward. In particular `values(foo)`&`values(bar)` and `names(foo, bar)` are not equivalent which has created [some confusions](https://github.com/rust-lang/rust/pull/98080).

Also the `names()` and `values()` form are not clear either and again created some confusions where peoples believed that `values()`&`values(foo)` could be reduced to just `values(foo)`.

To fix that the two new forms are made to be explicit and simpler. See the table of correspondence:
  - `names()` -> `exhaustive(names)`
  - `values()` -> `exhaustive(values)`
  - `names(foo)` -> `exhaustive(names)`&`configure(foo)`
  - `values(foo)` -> `configure(foo)`
  - `values(feat, "foo", "bar")` -> `configure(feat, "foo", "bar")`
  - `values(foo)`&`values(bar)` -> `configure(foo, bar)`
  - `names()`&`values()`&`values(my_cfg)` -> `exhaustive(names, values)`&`configure(my_cfg)`

Another benefits of the new syntax is that it allow for further options (like conditional checking for --cfg, currently always on) without syntax change.

The two previous forms are deprecated and will be removed once cargo and beta rustc have the necessary support.

</details>

This PR is the first part of the implementation of [MCP636 - Simplify and improve explicitness of the check-cfg syntax](https://github.com/rust-lang/compiler-team/issues/636).

## New `cfg` form

It introduces the new [`cfg` form](https://github.com/rust-lang/compiler-team/issues/636) and deprecate the other two:
```
rustc --check-cfg 'cfg(name1, ..., nameN, values("value1", "value2", ... "valueN"))'
```

## Default built-in names and values

It also changes the default for the built-in names and values checking.

 - Built-in values checking would always be activated as long as a `--check-cfg` argument is present
 - Built-in names checking would always be activated as long as a `--check-cfg` argument is present **unless** if any `cfg(any())` arg is passed

~~**Note: depends on https://github.com/rust-lang/rust/pull/111068 but is reviewable (last two commits)!**~~

Resolve https://github.com/rust-lang/compiler-team/issues/636

r? `@petrochenkov`
2023-10-17 19:07:21 +02:00
..
rustc Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things 2023-09-25 14:38:27 +00:00
rustc_abi docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_arena rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_ast Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstrieb 2023-10-15 13:23:55 +00:00
rustc_ast_lowering docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_ast_passes docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_ast_pretty Auto merge of #116822 - notriddle:notriddle/rust-logo, r=fmease 2023-10-17 04:41:20 +00:00
rustc_attr docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_baked_icu_data docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_borrowck Auto merge of #116822 - notriddle:notriddle/rust-logo, r=fmease 2023-10-17 04:41:20 +00:00
rustc_builtin_macros docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_codegen_cranelift docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_codegen_gcc docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_codegen_llvm docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_codegen_ssa Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstrieb 2023-10-15 13:23:55 +00:00
rustc_const_eval docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_data_structures docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_driver docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_driver_impl Auto merge of #116477 - nnethercote:tidy-alpha-deps, r=wesleywiser 2023-10-17 02:48:03 +00:00
rustc_error_codes docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_error_messages docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_errors Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebank 2023-10-16 06:26:20 +02:00
rustc_expand docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_feature docs: add Rust logo to more compiler crates 2023-10-16 15:38:08 -07:00
rustc_fluent_macro rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_fs_util
rustc_graphviz rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_hir Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum 2023-10-01 05:56:47 +00:00
rustc_hir_analysis Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk 2023-10-17 12:16:54 +00:00
rustc_hir_pretty Fiddle with State functions. 2023-10-11 10:46:55 +11:00
rustc_hir_typeck Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk 2023-10-17 12:16:54 +00:00
rustc_incremental Auto merge of #115964 - bjorn3:cgu_reuse_tracker_global_state, r=cjgillot 2023-10-13 00:09:30 +00:00
rustc_index Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
rustc_infer Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_interface Rollup merge of #111072 - Urgau:check-cfg-new-syntax, r=petrochenkov 2023-10-17 19:07:21 +02:00
rustc_lexer
rustc_lint Rename ACTIVE_FEATURES as UNSTABLE_FEATURES. 2023-10-16 08:17:23 +11:00
rustc_lint_defs Auto merge of #115822 - compiler-errors:stabilize-rpitit, r=jackh726 2023-10-14 07:29:08 +00:00
rustc_llvm rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_log use env variable to control thread ids in rustc_log 2023-10-10 09:39:47 +08:00
rustc_macros Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_metadata Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_middle Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk 2023-10-17 12:16:54 +00:00
rustc_mir_build Rollup merge of #116522 - bvanjoi:fix-115599, r=oli-obk 2023-10-15 21:29:07 +02:00
rustc_mir_dataflow Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_mir_transform coverage: Explain why we temporarily steal pending_dups 2023-10-16 21:05:46 +11:00
rustc_monomorphize rustc_monomorphize: Introduce check_fn_args_move_size() 2023-10-07 10:29:37 +02:00
rustc_parse Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstrieb 2023-10-15 13:23:55 +00:00
rustc_parse_format rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_passes Rename ACTIVE_FEATURES as UNSTABLE_FEATURES. 2023-10-16 08:17:23 +11:00
rustc_plugin_impl rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_privacy Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_query_impl rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_query_system Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_resolve Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_serialize rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_session Auto merge of #116731 - Alexendoo:hash-untracked-state, r=oli-obk 2023-10-16 16:33:42 +00:00
rustc_smir change fn name, return loc info, local name 2023-10-13 11:44:38 +03:00
rustc_span Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_symbol_mangling rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_target Rename ACTIVE_FEATURES as UNSTABLE_FEATURES. 2023-10-16 08:17:23 +11:00
rustc_trait_selection Auto merge of #116826 - nnethercote:fix-116780-116797, r=compiler-errors 2023-10-17 00:53:53 +00:00
rustc_traits Detect cycle errors hidden by opaques during monomorphization 2023-09-13 17:35:44 +00:00
rustc_transmute Remove the MaybeTransmutableQuery<&'l Dfa<...>, C> impl. 2023-10-06 11:25:32 +11:00
rustc_ty_utils Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
rustc_type_ir Avoid emitting the non_exhaustive error if other errors already occurred 2023-10-11 12:49:57 +00:00
stable_mir change fn name, return loc info, local name 2023-10-13 11:44:38 +03:00