Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ fn execute(opts: &Options) -> Result<i32> {
Ok(0)
}
Operation::ConfigOutputDefault { path } => {
let toml = Config::default().all_options().to_toml()?;
let toml = if is_nightly() {
Config::default().all_options().to_toml()?
} else {
Config::default().stable_options().to_toml()?
};

if let Some(path) = path {
let mut file = File::create(path)?;
file.write_all(toml.as_bytes())?;
Expand Down
16 changes: 16 additions & 0 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,22 @@ macro_rules! create_config {
}
}


#[allow(unreachable_pub)]
pub fn stable_options(&self) -> PartialConfig {
PartialConfig {
$(
$i: if $stb {
Some(self.$i.2.clone())
} else {
None
},
)+
}
}



#[allow(unreachable_pub)]
pub fn override_value(&mut self, key: &str, val: &str)
{
Expand Down
36 changes: 35 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,9 @@ mod test {
assert_eq!(s.contains(PRINT_DOCS_PARTIALLY_UNSTABLE_OPTION), true);
}

#[nightly_only_test]
#[test]
fn test_dump_default_config() {
fn test_dump_all_default_config() {
let default_config = format!(
r#"max_width = 100
hard_tabs = false
Expand Down Expand Up @@ -690,6 +691,39 @@ make_backup = false
assert_eq!(&toml, &default_config);
}

#[stable_only_test]
#[test]
fn test_dump_stable_default_config() {
let default_config = r#"max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
use_small_heuristics = "Default"
fn_call_width = 60
attr_fn_like_width = 70
struct_lit_width = 18
struct_variant_width = 35
array_width = 60
chain_width = 60
single_line_if_else_max_width = 50
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
short_array_element_width_threshold = 10
match_arm_leading_pipes = "Never"
fn_params_layout = "Tall"
match_block_trailing_comma = false
edition = "2015"
merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true
disable_all_formatting = false
"#;
let toml = Config::default().stable_options().to_toml().unwrap();
assert_eq!(&toml, &default_config);
}

#[stable_only_test]
#[test]
fn test_as_not_nightly_channel() {
Expand Down
Loading