@@ -44,7 +44,7 @@ pub mod sigpipe;
4444
4545pub const PRINT_KINDS : & [ ( & str , PrintKind ) ] = & [
4646 // tidy-alphabetical-start
47- ( "all-target-specs-json" , PrintKind :: AllTargetSpecs ) ,
47+ ( "all-target-specs-json" , PrintKind :: AllTargetSpecsJson ) ,
4848 ( "calling-conventions" , PrintKind :: CallingConventions ) ,
4949 ( "cfg" , PrintKind :: Cfg ) ,
5050 ( "check-cfg" , PrintKind :: CheckCfg ) ,
@@ -63,7 +63,7 @@ pub const PRINT_KINDS: &[(&str, PrintKind)] = &[
6363 ( "target-features" , PrintKind :: TargetFeatures ) ,
6464 ( "target-libdir" , PrintKind :: TargetLibdir ) ,
6565 ( "target-list" , PrintKind :: TargetList ) ,
66- ( "target-spec-json" , PrintKind :: TargetSpec ) ,
66+ ( "target-spec-json" , PrintKind :: TargetSpecJson ) ,
6767 ( "tls-models" , PrintKind :: TlsModels ) ,
6868 // tidy-alphabetical-end
6969] ;
@@ -873,27 +873,29 @@ pub struct PrintRequest {
873873
874874#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
875875pub enum PrintKind {
876+ // tidy-alphabetical-start
877+ AllTargetSpecsJson ,
878+ CallingConventions ,
879+ Cfg ,
880+ CheckCfg ,
881+ CodeModels ,
882+ CrateName ,
883+ DeploymentTarget ,
876884 FileNames ,
877885 HostTuple ,
886+ LinkArgs ,
887+ NativeStaticLibs ,
888+ RelocationModels ,
889+ SplitDebuginfo ,
890+ StackProtectorStrategies ,
878891 Sysroot ,
879- TargetLibdir ,
880- CrateName ,
881- Cfg ,
882- CheckCfg ,
883- CallingConventions ,
884- TargetList ,
885892 TargetCPUs ,
886893 TargetFeatures ,
887- RelocationModels ,
888- CodeModels ,
894+ TargetLibdir ,
895+ TargetList ,
896+ TargetSpecJson ,
889897 TlsModels ,
890- TargetSpec ,
891- AllTargetSpecs ,
892- NativeStaticLibs ,
893- StackProtectorStrategies ,
894- LinkArgs ,
895- SplitDebuginfo ,
896- DeploymentTarget ,
898+ // tidy-alphabetical-end
897899}
898900
899901#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq , Default ) ]
@@ -2030,49 +2032,13 @@ fn collect_print_requests(
20302032 prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |req| {
20312033 let ( req, out) = split_out_file_name ( & req) ;
20322034
2033- let kind = match PRINT_KINDS . iter ( ) . find ( |& & ( name, _) | name == req) {
2034- Some ( ( _, PrintKind :: TargetSpec ) ) => {
2035- if unstable_opts. unstable_options {
2036- PrintKind :: TargetSpec
2037- } else {
2038- early_dcx. early_fatal (
2039- "the `-Z unstable-options` flag must also be passed to \
2040- enable the target-spec-json print option",
2041- ) ;
2042- }
2043- }
2044- Some ( ( _, PrintKind :: AllTargetSpecs ) ) => {
2045- if unstable_opts. unstable_options {
2046- PrintKind :: AllTargetSpecs
2047- } else {
2048- early_dcx. early_fatal (
2049- "the `-Z unstable-options` flag must also be passed to \
2050- enable the all-target-specs-json print option",
2051- ) ;
2052- }
2053- }
2054- Some ( ( _, PrintKind :: CheckCfg ) ) => {
2055- if unstable_opts. unstable_options {
2056- PrintKind :: CheckCfg
2057- } else {
2058- early_dcx. early_fatal (
2059- "the `-Z unstable-options` flag must also be passed to \
2060- enable the check-cfg print option",
2061- ) ;
2062- }
2063- }
2064- Some ( & ( _, print_kind) ) => print_kind,
2065- None => {
2066- let prints =
2067- PRINT_KINDS . iter ( ) . map ( |( name, _) | format ! ( "`{name}`" ) ) . collect :: < Vec < _ > > ( ) ;
2068- let prints = prints. join ( ", " ) ;
2069-
2070- let mut diag =
2071- early_dcx. early_struct_fatal ( format ! ( "unknown print request: `{req}`" ) ) ;
2072- #[ allow( rustc:: diagnostic_outside_of_impl) ]
2073- diag. help ( format ! ( "valid print requests are: {prints}" ) ) ;
2074- diag. emit ( )
2075- }
2035+ let kind = if let Some ( ( print_name, print_kind) ) =
2036+ PRINT_KINDS . iter ( ) . find ( |& & ( name, _) | name == req)
2037+ {
2038+ check_print_request_stability ( early_dcx, unstable_opts, ( print_name, * print_kind) ) ;
2039+ * print_kind
2040+ } else {
2041+ emit_unknown_print_request_help ( early_dcx, req)
20762042 } ;
20772043
20782044 let out = out. unwrap_or ( OutFileName :: Stdout ) ;
@@ -2091,6 +2057,34 @@ fn collect_print_requests(
20912057 prints
20922058}
20932059
2060+ fn check_print_request_stability (
2061+ early_dcx : & EarlyDiagCtxt ,
2062+ unstable_opts : & UnstableOptions ,
2063+ ( print_name, print_kind) : ( & str , PrintKind ) ,
2064+ ) {
2065+ match print_kind {
2066+ PrintKind :: AllTargetSpecsJson | PrintKind :: CheckCfg | PrintKind :: TargetSpecJson
2067+ if !unstable_opts. unstable_options =>
2068+ {
2069+ early_dcx. early_fatal ( format ! (
2070+ "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \
2071+ print option"
2072+ ) ) ;
2073+ }
2074+ _ => { }
2075+ }
2076+ }
2077+
2078+ fn emit_unknown_print_request_help ( early_dcx : & EarlyDiagCtxt , req : & str ) -> ! {
2079+ let prints = PRINT_KINDS . iter ( ) . map ( |( name, _) | format ! ( "`{name}`" ) ) . collect :: < Vec < _ > > ( ) ;
2080+ let prints = prints. join ( ", " ) ;
2081+
2082+ let mut diag = early_dcx. early_struct_fatal ( format ! ( "unknown print request: `{req}`" ) ) ;
2083+ #[ allow( rustc:: diagnostic_outside_of_impl) ]
2084+ diag. help ( format ! ( "valid print requests are: {prints}" ) ) ;
2085+ diag. emit ( )
2086+ }
2087+
20942088pub fn parse_target_triple ( early_dcx : & EarlyDiagCtxt , matches : & getopts:: Matches ) -> TargetTuple {
20952089 match matches. opt_str ( "target" ) {
20962090 Some ( target) if target. ends_with ( ".json" ) => {
0 commit comments