@@ -65,7 +65,7 @@ macro_rules! create_config {
6565 // into a regex, it will be stored here
6666 pub license_template: Option <Regex >,
6767 // Unstable Options specified on the stable channel
68- configured_unstable_options: Option < Vec < String > >,
68+ configured_unstable_options: std :: collections :: HashMap < String , String >,
6969 // For each config item, we store a bool indicating whether it has
7070 // been accessed and the value, and a bool whether the option was
7171 // manually initialised, or taken from the default,
@@ -150,49 +150,48 @@ macro_rules! create_config {
150150 /// Returns None if using nightly or if no unstable options were set.
151151 /// Otherwise, return all unstable options set by the user.
152152 #[ 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 >> {
154154 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+ )
156163 } else {
157- self . configured_unstable_options . as_ref ( )
164+ None
158165 }
159166 }
160167
168+ /// Gather all unstable options specified by the user
161169 #[ allow( unreachable_pub) ]
162170 pub fn collect_unstable_options( & mut self ) {
163171 if crate :: is_nightly_channel!( ) {
164172 return
165173 }
166174
167- let mut unstable_options = vec![ ] ;
168175 let abort_option = "abort_on_unrecognised_options" ;
169176
170- $(
177+ $( {
171178 // self.$i.3 = 'is this a stable options'
172179 // self.$1.1 = 'was this set by the user'
173180 // the abort option is currently unstable so it needs to be special cased
174181 // 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+ ) ;
177186 }
178187
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+ } ) +
190189 }
191190
192191 /// Returns true if any unstable options were set while on the stable channel
193192 #[ allow( unreachable_pub) ]
194193 pub fn using_unstable_options_on_stable_channel( & self ) -> bool {
195- self . configured_unstable_options. is_some ( )
194+ ! self . configured_unstable_options. is_empty ( )
196195 }
197196
198197 /// Return a String warning users about all unstable options used on the stable channel
@@ -243,36 +242,17 @@ macro_rules! create_config {
243242 }
244243
245244 fn fill_from_parsed_config( mut self , parsed: PartialConfig , dir: & Path ) -> Config {
246- let mut unstable_options = vec![ ] ;
247245 $(
248246 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;
267249 }
268250 ) +
269- if unstable_options. len( ) > 0 {
270- self . configured_unstable_options = Some ( unstable_options) ;
271- }
272251 self . set_heuristics( ) ;
273252 self . set_license_template( ) ;
274253 self . set_ignore( dir) ;
275254 self . set_merge_imports( ) ;
255+ self . collect_unstable_options( ) ;
276256 self
277257 }
278258
@@ -545,7 +525,7 @@ macro_rules! create_config {
545525 fn default ( ) -> Config {
546526 Config {
547527 license_template: None ,
548- configured_unstable_options: None ,
528+ configured_unstable_options: std :: collections :: HashMap :: new ( ) ,
549529 $(
550530 $i: ( Cell :: new( false ) , false , $def, $stb) ,
551531 ) +
0 commit comments