File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,22 @@ macro_rules! create_config {
147
147
ConfigWasSet ( self )
148
148
}
149
149
150
+ /// Returns None if using nightly or if no unstable options were set.
151
+ /// Otherwise, return all unstable options set by the user.
152
+ #[ allow( unreachable_pub) ]
153
+ pub fn unstable_options_set_on_stable_channel( & self ) -> Option <& Vec <String >> {
154
+ if crate :: is_nightly_channel!( ) {
155
+ None
156
+ } else {
157
+ self . configured_unstable_options. as_ref( )
158
+ }
159
+ }
160
+
161
+ /// Returns true if any unstable options were set while on the stable channel
162
+ #[ allow( unreachable_pub) ]
163
+ pub fn using_unstable_options_on_stable_channel( & self ) -> bool {
164
+ self . configured_unstable_options. is_some( )
165
+ }
150
166
fn fill_from_parsed_config( mut self , parsed: PartialConfig , dir: & Path ) -> Config {
151
167
let mut unstable_options = vec![ ] ;
152
168
$(
Original file line number Diff line number Diff line change @@ -549,6 +549,35 @@ mod test {
549
549
assert ! ( config. license_template. is_none( ) ) ;
550
550
}
551
551
552
+ #[ test]
553
+ fn test_on_stable_get_all_unstable_options_set_in_toml ( ) {
554
+ if crate :: is_nightly_channel!( ) {
555
+ // This test requires non-nightly
556
+ return ;
557
+ }
558
+ let toml = r#"
559
+ reorder_impl_items = true
560
+ "# ;
561
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
562
+ assert_eq ! (
563
+ config. unstable_options_set_on_stable_channel( ) . unwrap( ) ,
564
+ & vec![ "reorder_impl_items = true" ]
565
+ )
566
+ }
567
+
568
+ #[ test]
569
+ fn test_on_stable_are_any_unstable_options_set_in_toml ( ) {
570
+ if crate :: is_nightly_channel!( ) {
571
+ // This test requires non-nightly
572
+ return ;
573
+ }
574
+ let toml = r#"
575
+ reorder_impl_items = true
576
+ "# ;
577
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
578
+ assert ! ( config. using_unstable_options_on_stable_channel( ) )
579
+ }
580
+
552
581
#[ test]
553
582
fn test_dump_default_config ( ) {
554
583
let default_config = format ! (
You can’t perform that action at this time.
0 commit comments