@@ -20,7 +20,7 @@ use rustc_data_structures::profiling::print_time_passes_entry;
20
20
use rustc_data_structures:: sync:: SeqCst ;
21
21
use rustc_errors:: registry:: { InvalidErrorCode , Registry } ;
22
22
use rustc_errors:: { ErrorReported , PResult } ;
23
- use rustc_feature:: { find_gated_cfg, UnstableFeatures } ;
23
+ use rustc_feature:: find_gated_cfg;
24
24
use rustc_hir:: def_id:: LOCAL_CRATE ;
25
25
use rustc_interface:: util:: { self , collect_crate_types, get_builtin_codegen_backend} ;
26
26
use rustc_interface:: { interface, Queries } ;
@@ -746,9 +746,6 @@ impl RustcDefaultCalls {
746
746
}
747
747
}
748
748
Cfg => {
749
- let allow_unstable_cfg =
750
- UnstableFeatures :: from_environment ( ) . is_nightly_build ( ) ;
751
-
752
749
let mut cfgs = sess
753
750
. parse_sess
754
751
. config
@@ -763,7 +760,7 @@ impl RustcDefaultCalls {
763
760
// it, this is intended to get into Cargo and then go
764
761
// through to build scripts.
765
762
if ( name != sym:: target_feature || value != Some ( sym:: crt_dash_static) )
766
- && !allow_unstable_cfg
763
+ && !sess . is_nightly_build ( )
767
764
&& find_gated_cfg ( |cfg_sym| cfg_sym == name) . is_some ( )
768
765
{
769
766
return None ;
@@ -814,14 +811,14 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
814
811
}
815
812
}
816
813
817
- fn usage ( verbose : bool , include_unstable_options : bool ) {
814
+ fn usage ( verbose : bool , include_unstable_options : bool , nightly_build : bool ) {
818
815
let groups = if verbose { config:: rustc_optgroups ( ) } else { config:: rustc_short_optgroups ( ) } ;
819
816
let mut options = getopts:: Options :: new ( ) ;
820
817
for option in groups. iter ( ) . filter ( |x| include_unstable_options || x. is_stable ( ) ) {
821
818
( option. apply ) ( & mut options) ;
822
819
}
823
820
let message = "Usage: rustc [OPTIONS] INPUT" ;
824
- let nightly_help = if nightly_options :: is_nightly_build ( ) {
821
+ let nightly_help = if nightly_build {
825
822
"\n -Z help Print unstable compiler options"
826
823
} else {
827
824
""
@@ -831,7 +828,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
831
828
} else {
832
829
"\n --help -v Print the full set of options rustc accepts"
833
830
} ;
834
- let at_path = if verbose && nightly_options :: is_nightly_build ( ) {
831
+ let at_path = if verbose && nightly_build {
835
832
" @path Read newline separated options from `path`\n "
836
833
} else {
837
834
""
@@ -1034,7 +1031,9 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1034
1031
if args. is_empty ( ) {
1035
1032
// user did not write `-v` nor `-Z unstable-options`, so do not
1036
1033
// include that extra information.
1037
- usage ( false , false ) ;
1034
+ let nightly_build =
1035
+ rustc_feature:: UnstableFeatures :: from_environment ( None ) . is_nightly_build ( ) ;
1036
+ usage ( false , false , nightly_build) ;
1038
1037
return None ;
1039
1038
}
1040
1039
@@ -1063,7 +1062,9 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1063
1062
1064
1063
if matches. opt_present ( "h" ) || matches. opt_present ( "help" ) {
1065
1064
// Only show unstable options in --help if we accept unstable options.
1066
- usage ( matches. opt_present ( "verbose" ) , nightly_options:: is_unstable_enabled ( & matches) ) ;
1065
+ let unstable_enabled = nightly_options:: is_unstable_enabled ( & matches) ;
1066
+ let nightly_build = nightly_options:: match_is_nightly_build ( & matches) ;
1067
+ usage ( matches. opt_present ( "verbose" ) , unstable_enabled, nightly_build) ;
1067
1068
return None ;
1068
1069
}
1069
1070
0 commit comments