@@ -60,13 +60,25 @@ struct CliOptions {
6060 verbose : bool ,
6161 write_mode : Option < WriteMode > ,
6262 file_lines : FileLines , // Default is all lines in all files.
63+ unstable_features : bool ,
6364}
6465
6566impl CliOptions {
6667 fn from_matches ( matches : & Matches ) -> FmtResult < CliOptions > {
6768 let mut options = CliOptions :: default ( ) ;
6869 options. skip_children = matches. opt_present ( "skip-children" ) ;
6970 options. verbose = matches. opt_present ( "verbose" ) ;
71+ let unstable_features = matches. opt_present ( "unstable_features" ) ;
72+ let rust_nightly = option_env ! ( "CFG_RELEASE_CHANNEL" )
73+ . map ( |c| c == "nightly" )
74+ . unwrap_or ( false ) ;
75+ if unstable_features && !rust_nightly {
76+ return Err ( FmtError :: from ( format ! (
77+ "Unstable features are only available on Nightly channel"
78+ ) ) ) ;
79+ } else {
80+ options. unstable_features = unstable_features;
81+ }
7082
7183 if let Some ( ref write_mode) = matches. opt_str ( "write-mode" ) {
7284 if let Ok ( write_mode) = WriteMode :: from_str ( write_mode) {
@@ -89,6 +101,7 @@ impl CliOptions {
89101 config. set ( ) . skip_children ( self . skip_children ) ;
90102 config. set ( ) . verbose ( self . verbose ) ;
91103 config. set ( ) . file_lines ( self . file_lines ) ;
104+ config. set ( ) . unstable_features ( self . unstable_features ) ;
92105 if let Some ( write_mode) = self . write_mode {
93106 config. set ( ) . write_mode ( write_mode) ;
94107 }
@@ -120,6 +133,12 @@ fn make_opts() -> Options {
120133 ) ;
121134 opts. optflag ( "" , "skip-children" , "don't reformat child modules" ) ;
122135
136+ opts. optflag (
137+ "" ,
138+ "unstable-features" ,
139+ "Enables unstable features. Only available on nightly channel" ,
140+ ) ;
141+
123142 opts. optflag (
124143 "" ,
125144 "config-help" ,
0 commit comments