@@ -1789,34 +1789,49 @@ fn collect_print_requests(
17891789 cg. target_feature = String :: new ( ) ;
17901790 }
17911791
1792- prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |s| match & * s {
1793- "crate-name" => PrintRequest :: CrateName ,
1794- "file-names" => PrintRequest :: FileNames ,
1795- "sysroot" => PrintRequest :: Sysroot ,
1796- "target-libdir" => PrintRequest :: TargetLibdir ,
1797- "cfg" => PrintRequest :: Cfg ,
1798- "calling-conventions" => PrintRequest :: CallingConventions ,
1799- "target-list" => PrintRequest :: TargetList ,
1800- "target-cpus" => PrintRequest :: TargetCPUs ,
1801- "target-features" => PrintRequest :: TargetFeatures ,
1802- "relocation-models" => PrintRequest :: RelocationModels ,
1803- "code-models" => PrintRequest :: CodeModels ,
1804- "tls-models" => PrintRequest :: TlsModels ,
1805- "native-static-libs" => PrintRequest :: NativeStaticLibs ,
1806- "stack-protector-strategies" => PrintRequest :: StackProtectorStrategies ,
1807- "target-spec-json" => {
1808- if unstable_opts. unstable_options {
1809- PrintRequest :: TargetSpec
1810- } else {
1792+ const PRINT_REQUESTS : & [ ( & str , PrintRequest ) ] = & [
1793+ ( "crate-name" , PrintRequest :: CrateName ) ,
1794+ ( "file-names" , PrintRequest :: FileNames ) ,
1795+ ( "sysroot" , PrintRequest :: Sysroot ) ,
1796+ ( "target-libdir" , PrintRequest :: TargetLibdir ) ,
1797+ ( "cfg" , PrintRequest :: Cfg ) ,
1798+ ( "calling-conventions" , PrintRequest :: CallingConventions ) ,
1799+ ( "target-list" , PrintRequest :: TargetList ) ,
1800+ ( "target-cpus" , PrintRequest :: TargetCPUs ) ,
1801+ ( "target-features" , PrintRequest :: TargetFeatures ) ,
1802+ ( "relocation-models" , PrintRequest :: RelocationModels ) ,
1803+ ( "code-models" , PrintRequest :: CodeModels ) ,
1804+ ( "tls-models" , PrintRequest :: TlsModels ) ,
1805+ ( "native-static-libs" , PrintRequest :: NativeStaticLibs ) ,
1806+ ( "stack-protector-strategies" , PrintRequest :: StackProtectorStrategies ) ,
1807+ ( "target-spec-json" , PrintRequest :: TargetSpec ) ,
1808+ ( "link-args" , PrintRequest :: LinkArgs ) ,
1809+ ] ;
1810+
1811+ prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |req| {
1812+ match PRINT_REQUESTS . iter ( ) . find ( |& & ( name, _) | name == req) {
1813+ Some ( ( _, PrintRequest :: TargetSpec ) ) => {
1814+ if unstable_opts. unstable_options {
1815+ PrintRequest :: TargetSpec
1816+ } else {
1817+ early_error (
1818+ error_format,
1819+ "the `-Z unstable-options` flag must also be passed to \
1820+ enable the target-spec-json print option",
1821+ ) ;
1822+ }
1823+ }
1824+ Some ( & ( _, print_request) ) => print_request,
1825+ None => {
1826+ let prints =
1827+ PRINT_REQUESTS . iter ( ) . map ( |( name, _) | format ! ( "`{name}`" ) ) . collect :: < Vec < _ > > ( ) ;
1828+ let prints = prints. join ( ", " ) ;
18111829 early_error (
18121830 error_format,
1813- "the `-Z unstable-options` flag must also be passed to \
1814- enable the target-spec-json print option",
1831+ & format ! ( "unknown print request `{req}`. Valid print requests are: {prints}" ) ,
18151832 ) ;
18161833 }
18171834 }
1818- "link-args" => PrintRequest :: LinkArgs ,
1819- req => early_error ( error_format, & format ! ( "unknown print request `{req}`" ) ) ,
18201835 } ) ) ;
18211836
18221837 prints
0 commit comments