about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-05-29 03:25:07 +0100
committerGitHub <noreply@github.com>2024-05-29 03:25:07 +0100
commit7e441a11a151098a0ff928fdeb52492798678ede (patch)
tree749ba591bfb7ee5f358bb0a9f026581591d7b887 /compiler/rustc_session/src
parent2d3b1e014be923767f36c4b231feb2672e853043 (diff)
parentac59bdc20cf07422557b5dc512ee6749a73c9414 (diff)
downloadrust-7e441a11a151098a0ff928fdeb52492798678ede.tar.gz
rust-7e441a11a151098a0ff928fdeb52492798678ede.zip
Rollup merge of #124320 - Urgau:print-check-cfg, r=petrochenkov
Add `--print=check-cfg` to get the expected configs

This PR adds a new `--print` variant `check-cfg` to get the expected configs.

Details and rational can be found on the MCP: https://github.com/rust-lang/compiler-team/issues/743

``@rustbot`` label +F-check-cfg +S-waiting-on-MCP
r? ``@petrochenkov``
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/config.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index c90da966e70..0287085ad60 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -773,6 +773,7 @@ pub enum PrintKind {
     TargetLibdir,
     CrateName,
     Cfg,
+    CheckCfg,
     CallingConventions,
     TargetList,
     TargetCPUs,
@@ -1443,7 +1444,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
             "",
             "print",
             "Compiler information to print on stdout",
-            "[crate-name|file-names|sysroot|target-libdir|cfg|calling-conventions|\
+            "[crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|\
              target-list|target-cpus|target-features|relocation-models|code-models|\
              tls-models|target-spec-json|all-target-specs-json|native-static-libs|\
              stack-protector-strategies|link-args|deployment-target]",
@@ -1859,6 +1860,7 @@ fn collect_print_requests(
         ("all-target-specs-json", PrintKind::AllTargetSpecs),
         ("calling-conventions", PrintKind::CallingConventions),
         ("cfg", PrintKind::Cfg),
+        ("check-cfg", PrintKind::CheckCfg),
         ("code-models", PrintKind::CodeModels),
         ("crate-name", PrintKind::CrateName),
         ("deployment-target", PrintKind::DeploymentTarget),
@@ -1908,6 +1910,16 @@ fn collect_print_requests(
                     );
                 }
             }
+            Some((_, PrintKind::CheckCfg)) => {
+                if unstable_opts.unstable_options {
+                    PrintKind::CheckCfg
+                } else {
+                    early_dcx.early_fatal(
+                        "the `-Z unstable-options` flag must also be passed to \
+                         enable the check-cfg print option",
+                    );
+                }
+            }
             Some(&(_, print_kind)) => print_kind,
             None => {
                 let prints =