@@ -545,6 +545,7 @@ pub enum PrintRequest {
545545 NativeStaticLibs ,
546546 StackProtectorStrategies ,
547547 LinkArgs ,
548+ RustcPath ,
548549}
549550
550551pub enum Input {
@@ -1777,6 +1778,20 @@ fn collect_print_requests(
17771778 cg. target_feature = String :: new ( ) ;
17781779 }
17791780
1781+ let gate = |req, opt| {
1782+ if unstable_opts. unstable_options {
1783+ req
1784+ } else {
1785+ early_error (
1786+ error_format,
1787+ & format ! (
1788+ "the `-Z unstable-options` flag must also be passed to \
1789+ enable the {opt} print option",
1790+ ) ,
1791+ ) ;
1792+ }
1793+ } ;
1794+
17801795 prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |s| match & * s {
17811796 "crate-name" => PrintRequest :: CrateName ,
17821797 "file-names" => PrintRequest :: FileNames ,
@@ -1791,18 +1806,9 @@ fn collect_print_requests(
17911806 "tls-models" => PrintRequest :: TlsModels ,
17921807 "native-static-libs" => PrintRequest :: NativeStaticLibs ,
17931808 "stack-protector-strategies" => PrintRequest :: StackProtectorStrategies ,
1794- "target-spec-json" => {
1795- if unstable_opts. unstable_options {
1796- PrintRequest :: TargetSpec
1797- } else {
1798- early_error (
1799- error_format,
1800- "the `-Z unstable-options` flag must also be passed to \
1801- enable the target-spec-json print option",
1802- ) ;
1803- }
1804- }
1809+ "target-spec-json" => gate ( PrintRequest :: TargetSpec , "target-spec-json" ) ,
18051810 "link-args" => PrintRequest :: LinkArgs ,
1811+ "rustc-path" => gate ( PrintRequest :: RustcPath , "rustc-path" ) ,
18061812 req => early_error ( error_format, & format ! ( "unknown print request `{req}`" ) ) ,
18071813 } ) ) ;
18081814
0 commit comments