@@ -44,7 +44,7 @@ pub mod sigpipe;
44
44
45
45
pub const PRINT_KINDS : & [ ( & str , PrintKind ) ] = & [
46
46
// tidy-alphabetical-start
47
- ( "all-target-specs-json" , PrintKind :: AllTargetSpecs ) ,
47
+ ( "all-target-specs-json" , PrintKind :: AllTargetSpecsJson ) ,
48
48
( "calling-conventions" , PrintKind :: CallingConventions ) ,
49
49
( "cfg" , PrintKind :: Cfg ) ,
50
50
( "check-cfg" , PrintKind :: CheckCfg ) ,
@@ -63,7 +63,7 @@ pub const PRINT_KINDS: &[(&str, PrintKind)] = &[
63
63
( "target-features" , PrintKind :: TargetFeatures ) ,
64
64
( "target-libdir" , PrintKind :: TargetLibdir ) ,
65
65
( "target-list" , PrintKind :: TargetList ) ,
66
- ( "target-spec-json" , PrintKind :: TargetSpec ) ,
66
+ ( "target-spec-json" , PrintKind :: TargetSpecJson ) ,
67
67
( "tls-models" , PrintKind :: TlsModels ) ,
68
68
// tidy-alphabetical-end
69
69
] ;
@@ -873,27 +873,29 @@ pub struct PrintRequest {
873
873
874
874
#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
875
875
pub enum PrintKind {
876
+ // tidy-alphabetical-start
877
+ AllTargetSpecsJson ,
878
+ CallingConventions ,
879
+ Cfg ,
880
+ CheckCfg ,
881
+ CodeModels ,
882
+ CrateName ,
883
+ DeploymentTarget ,
876
884
FileNames ,
877
885
HostTuple ,
886
+ LinkArgs ,
887
+ NativeStaticLibs ,
888
+ RelocationModels ,
889
+ SplitDebuginfo ,
890
+ StackProtectorStrategies ,
878
891
Sysroot ,
879
- TargetLibdir ,
880
- CrateName ,
881
- Cfg ,
882
- CheckCfg ,
883
- CallingConventions ,
884
- TargetList ,
885
892
TargetCPUs ,
886
893
TargetFeatures ,
887
- RelocationModels ,
888
- CodeModels ,
894
+ TargetLibdir ,
895
+ TargetList ,
896
+ TargetSpecJson ,
889
897
TlsModels ,
890
- TargetSpec ,
891
- AllTargetSpecs ,
892
- NativeStaticLibs ,
893
- StackProtectorStrategies ,
894
- LinkArgs ,
895
- SplitDebuginfo ,
896
- DeploymentTarget ,
898
+ // tidy-alphabetical-end
897
899
}
898
900
899
901
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq , Default ) ]
@@ -2030,49 +2032,13 @@ fn collect_print_requests(
2030
2032
prints. extend ( matches. opt_strs ( "print" ) . into_iter ( ) . map ( |req| {
2031
2033
let ( req, out) = split_out_file_name ( & req) ;
2032
2034
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)
2076
2042
} ;
2077
2043
2078
2044
let out = out. unwrap_or ( OutFileName :: Stdout ) ;
@@ -2091,6 +2057,34 @@ fn collect_print_requests(
2091
2057
prints
2092
2058
}
2093
2059
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
+
2094
2088
pub fn parse_target_triple ( early_dcx : & EarlyDiagCtxt , matches : & getopts:: Matches ) -> TargetTuple {
2095
2089
match matches. opt_str ( "target" ) {
2096
2090
Some ( target) if target. ends_with ( ".json" ) => {
0 commit comments