diff options
| author | bors <bors@rust-lang.org> | 2024-01-13 06:17:46 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-13 06:17:46 +0000 | 
| commit | 7585c62658540e168b5fe9aa29677b68633b7e16 (patch) | |
| tree | 616a7fc014ee2b9d98aefcc8fa2dab167bfe4728 /compiler/rustc_interface/src | |
| parent | 89110dafe79621fa07d6cd7c8493dd1d0a83cfaf (diff) | |
| parent | 15078c25d692233b7d7a0ba8b977326929320887 (diff) | |
| download | rust-7585c62658540e168b5fe9aa29677b68633b7e16.tar.gz rust-7585c62658540e168b5fe9aa29677b68633b7e16.zip | |
Auto merge of #119473 - Urgau:check-cfg-explicit-none, r=petrochenkov
Add explicit `none()` value variant in check-cfg
This PR adds an explicit none value variant in check-cfg values: `values(none())`.
Currently the only way to define the none variant is with an empty `values()` which means that if someone has a cfg that takes none and strings they need to use two invocations: `--check-cfg=cfg(foo) --check-cfg=cfg(foo, values("bar"))`.
Which would now be `--check-cfg=cfg(foo, values(none(),"bar"))`, this is simpler and easier to understand.
`--check-cfg=cfg(foo)`, `--check-cfg=cfg(foo, values())` and `--check-cfg=cfg(foo, values(none()))` would be equivalent.
*Another motivation for doing this is to make empty `values()` actually means no-values, but this is orthogonal to this PR and adding `none()` is sufficient in it-self.*
`@rustbot` label +F-check-cfg
r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 03335996c03..32fba6ade88 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -202,8 +202,15 @@ pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec<String>) -> CheckCfg { if !args.is_empty() { error!("`any()` must be empty"); } + } else if arg.has_name(sym::none) + && let Some(args) = arg.meta_item_list() + { + values.insert(None); + if !args.is_empty() { + error!("`none()` must be empty"); + } } else { - error!("`values()` arguments must be string literals or `any()`"); + error!("`values()` arguments must be string literals, `none()` or `any()`"); } } } else { | 
