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