@@ -60,13 +60,25 @@ struct CliOptions {
60
60
verbose : bool ,
61
61
write_mode : Option < WriteMode > ,
62
62
file_lines : FileLines , // Default is all lines in all files.
63
+ unstable_features : bool ,
63
64
}
64
65
65
66
impl CliOptions {
66
67
fn from_matches ( matches : & Matches ) -> FmtResult < CliOptions > {
67
68
let mut options = CliOptions :: default ( ) ;
68
69
options. skip_children = matches. opt_present ( "skip-children" ) ;
69
70
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
+ }
70
82
71
83
if let Some ( ref write_mode) = matches. opt_str ( "write-mode" ) {
72
84
if let Ok ( write_mode) = WriteMode :: from_str ( write_mode) {
@@ -89,6 +101,7 @@ impl CliOptions {
89
101
config. set ( ) . skip_children ( self . skip_children ) ;
90
102
config. set ( ) . verbose ( self . verbose ) ;
91
103
config. set ( ) . file_lines ( self . file_lines ) ;
104
+ config. set ( ) . unstable_features ( self . unstable_features ) ;
92
105
if let Some ( write_mode) = self . write_mode {
93
106
config. set ( ) . write_mode ( write_mode) ;
94
107
}
@@ -120,6 +133,12 @@ fn make_opts() -> Options {
120
133
) ;
121
134
opts. optflag ( "" , "skip-children" , "don't reformat child modules" ) ;
122
135
136
+ opts. optflag (
137
+ "" ,
138
+ "unstable-features" ,
139
+ "Enables unstable features. Only available on nightly channel" ,
140
+ ) ;
141
+
123
142
opts. optflag (
124
143
"" ,
125
144
"config-help" ,
0 commit comments