@@ -2069,7 +2069,8 @@ fn collect_print_requests(
2069
2069
check_print_request_stability ( early_dcx, unstable_opts, ( print_name, * print_kind) ) ;
2070
2070
* print_kind
2071
2071
} else {
2072
- emit_unknown_print_request_help ( early_dcx, req)
2072
+ let is_nightly = nightly_options:: match_is_nightly_build ( matches) ;
2073
+ emit_unknown_print_request_help ( early_dcx, req, is_nightly)
2073
2074
} ;
2074
2075
2075
2076
let out = out. unwrap_or ( OutFileName :: Stdout ) ;
@@ -2093,25 +2094,37 @@ fn check_print_request_stability(
2093
2094
unstable_opts : & UnstableOptions ,
2094
2095
( print_name, print_kind) : ( & str , PrintKind ) ,
2095
2096
) {
2097
+ if !is_print_request_stability ( print_kind) && !unstable_opts. unstable_options {
2098
+ early_dcx. early_fatal ( format ! (
2099
+ "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \
2100
+ print option"
2101
+ ) ) ;
2102
+ }
2103
+ }
2104
+
2105
+ fn is_print_request_stability ( print_kind : PrintKind ) -> bool {
2096
2106
match print_kind {
2097
2107
PrintKind :: AllTargetSpecsJson
2098
2108
| PrintKind :: CheckCfg
2099
2109
| PrintKind :: CrateRootLintLevels
2100
2110
| PrintKind :: SupportedCrateTypes
2101
- | PrintKind :: TargetSpecJson
2102
- if !unstable_opts. unstable_options =>
2103
- {
2104
- early_dcx. early_fatal ( format ! (
2105
- "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \
2106
- print option"
2107
- ) ) ;
2108
- }
2109
- _ => { }
2111
+ | PrintKind :: TargetSpecJson => false ,
2112
+ _ => true ,
2110
2113
}
2111
2114
}
2112
2115
2113
- fn emit_unknown_print_request_help ( early_dcx : & EarlyDiagCtxt , req : & str ) -> ! {
2114
- let prints = PRINT_KINDS . iter ( ) . map ( |( name, _) | format ! ( "`{name}`" ) ) . collect :: < Vec < _ > > ( ) ;
2116
+ fn emit_unknown_print_request_help ( early_dcx : & EarlyDiagCtxt , req : & str , is_nightly : bool ) -> ! {
2117
+ let prints = PRINT_KINDS
2118
+ . iter ( )
2119
+ . filter_map ( |( name, kind) | {
2120
+ // If we're not on nightly, we don't want to print unstable options
2121
+ if !is_nightly && !is_print_request_stability ( * kind) {
2122
+ None
2123
+ } else {
2124
+ Some ( format ! ( "`{name}`" ) )
2125
+ }
2126
+ } )
2127
+ . collect :: < Vec < _ > > ( ) ;
2115
2128
let prints = prints. join ( ", " ) ;
2116
2129
2117
2130
let mut diag = early_dcx. early_struct_fatal ( format ! ( "unknown print request: `{req}`" ) ) ;
0 commit comments