From ac59bdc20cf07422557b5dc512ee6749a73c9414 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 22 Apr 2024 23:47:48 +0200 Subject: Add `--print=check-cfg` to get the expected configs --- compiler/rustc_driver_impl/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'compiler/rustc_driver_impl/src') diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index b3cba4dbfc2..cf9d0fe794f 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -804,6 +804,39 @@ fn print_crate_info( println_info!("{cfg}"); } } + CheckCfg => { + let mut check_cfgs: Vec = Vec::with_capacity(410); + + // INSTABILITY: We are sorting the output below. + #[allow(rustc::potential_query_instability)] + for (name, expected_values) in &sess.psess.check_config.expecteds { + use crate::config::ExpectedValues; + match expected_values { + ExpectedValues::Any => check_cfgs.push(format!("{name}=any()")), + ExpectedValues::Some(values) => { + check_cfgs.extend(values.iter().map(|value| { + if let Some(value) = value { + format!("{name}=\"{value}\"") + } else { + name.to_string() + } + })) + } + } + } + + check_cfgs.sort_unstable(); + if !sess.psess.check_config.exhaustive_names { + if !sess.psess.check_config.exhaustive_values { + println_info!("any()=any()"); + } else { + println_info!("any()"); + } + } + for check_cfg in check_cfgs { + println_info!("{check_cfg}"); + } + } CallingConventions => { let mut calling_conventions = rustc_target::spec::abi::all_names(); calling_conventions.sort_unstable(); -- cgit 1.4.1-3-g733a5