@@ -65,7 +65,7 @@ macro_rules! create_config {
65
65
// into a regex, it will be stored here
66
66
pub license_template: Option <Regex >,
67
67
// Unstable Options specified on the stable channel
68
- configured_unstable_options: Option < Vec < String > >,
68
+ configured_unstable_options: std :: collections :: HashMap < String , String >,
69
69
// For each config item, we store a bool indicating whether it has
70
70
// been accessed and the value, and a bool whether the option was
71
71
// manually initialised, or taken from the default,
@@ -150,49 +150,48 @@ macro_rules! create_config {
150
150
/// Returns None if using nightly or if no unstable options were set.
151
151
/// Otherwise, return all unstable options set by the user.
152
152
#[ allow( unreachable_pub) ]
153
- pub fn unstable_options_set_on_stable_channel( & self ) -> Option <& Vec <String >> {
153
+ pub fn unstable_options_set_on_stable_channel( & self ) -> Option <Vec <String >> {
154
154
if crate :: is_nightly_channel!( ) {
155
- None
155
+ return None ;
156
+ }
157
+
158
+ if self . using_unstable_options_on_stable_channel( ) {
159
+ Some ( self . configured_unstable_options. iter( )
160
+ . map( |( k, v) | format!( "{} = {}" , k, v) )
161
+ . collect:: <Vec <_>>( )
162
+ )
156
163
} else {
157
- self . configured_unstable_options . as_ref ( )
164
+ None
158
165
}
159
166
}
160
167
168
+ /// Gather all unstable options specified by the user
161
169
#[ allow( unreachable_pub) ]
162
170
pub fn collect_unstable_options( & mut self ) {
163
171
if crate :: is_nightly_channel!( ) {
164
172
return
165
173
}
166
174
167
- let mut unstable_options = vec![ ] ;
168
175
let abort_option = "abort_on_unrecognised_options" ;
169
176
170
- $(
177
+ $( {
171
178
// self.$i.3 = 'is this a stable options'
172
179
// self.$1.1 = 'was this set by the user'
173
180
// the abort option is currently unstable so it needs to be special cased
174
181
// otherwise we would abort when using it.
175
- if !self . $i. 3 && self . $i. 1 && stringify!( $i) != abort_option {
176
- unstable_options. push( format!( "{} = {:?}" , stringify!( $i) , self . $i. 2 ) ) ;
182
+ if !( self . $i. 3 ) && self . $i. 1 && stringify!( $i) != abort_option {
183
+ self . configured_unstable_options. insert(
184
+ stringify!( $i) . to_owned( ) , format!( "{:?}" , self . $i. 2 )
185
+ ) ;
177
186
}
178
187
179
- ) +
180
-
181
- if unstable_options. len( ) > 0 {
182
- if let Some ( mut options) = self . configured_unstable_options. take( ) {
183
- options. append( & mut unstable_options) ;
184
- options. sort( ) ;
185
- options. dedup( ) ;
186
- } else {
187
- self . configured_unstable_options. replace( unstable_options) ;
188
- }
189
- }
188
+ } ) +
190
189
}
191
190
192
191
/// Returns true if any unstable options were set while on the stable channel
193
192
#[ allow( unreachable_pub) ]
194
193
pub fn using_unstable_options_on_stable_channel( & self ) -> bool {
195
- self . configured_unstable_options. is_some ( )
194
+ ! self . configured_unstable_options. is_empty ( )
196
195
}
197
196
198
197
/// Return a String warning users about all unstable options used on the stable channel
@@ -243,36 +242,17 @@ macro_rules! create_config {
243
242
}
244
243
245
244
fn fill_from_parsed_config( mut self , parsed: PartialConfig , dir: & Path ) -> Config {
246
- let mut unstable_options = vec![ ] ;
247
245
$(
248
246
if let Some ( val) = parsed. $i {
249
- if self . $i. 3 {
250
- self . $i. 1 = true ;
251
- self . $i. 2 = val;
252
- } else {
253
- if crate :: is_nightly_channel!( ) {
254
- self . $i. 1 = true ;
255
- self . $i. 2 = val;
256
- } else {
257
- // only set abort_on_unrecognised_options, and store all other
258
- // nightly only options
259
- if stringify!( $i) != "abort_on_unrecognised_options" {
260
- unstable_options. push( format!( "{} = {:?}" , stringify!( $i) , val) ) ;
261
- } else {
262
- self . $i. 1 = true ;
263
- self . $i. 2 = val;
264
- }
265
- }
266
- }
247
+ self . $i. 1 = true ;
248
+ self . $i. 2 = val;
267
249
}
268
250
) +
269
- if unstable_options. len( ) > 0 {
270
- self . configured_unstable_options = Some ( unstable_options) ;
271
- }
272
251
self . set_heuristics( ) ;
273
252
self . set_license_template( ) ;
274
253
self . set_ignore( dir) ;
275
254
self . set_merge_imports( ) ;
255
+ self . collect_unstable_options( ) ;
276
256
self
277
257
}
278
258
@@ -545,7 +525,7 @@ macro_rules! create_config {
545
525
fn default ( ) -> Config {
546
526
Config {
547
527
license_template: None ,
548
- configured_unstable_options: None ,
528
+ configured_unstable_options: std :: collections :: HashMap :: new ( ) ,
549
529
$(
550
530
$i: ( Cell :: new( false ) , false , $def, $stb) ,
551
531
) +
0 commit comments