+
+ #[cfg(test)]
+ mod deprecated_option_merge_imports {
+ use super::*;
+
+ #[test]
+ fn test_old_option_set() {
+ if !crate::is_nightly_channel!() {
+ return;
+ }
+ let toml = r#"
+ unstable_features = true
+ merge_imports = true
+ "#;
+ let config = Config::from_toml(toml, Path::new("")).unwrap();
+ assert_eq!(config.imports_granularity(), ImportGranularity::Crate);
+ }
+
+ #[test]
+ fn test_both_set() {
+ if !crate::is_nightly_channel!() {
+ return;
+ }
+ let toml = r#"
+ unstable_features = true
+ merge_imports = true
+ imports_granularity = "Preserve"
+ "#;
+ let config = Config::from_toml(toml, Path::new("")).unwrap();
+ assert_eq!(config.imports_granularity(), ImportGranularity::Preserve);
+ }
+
+ #[test]
+ fn test_new_overridden() {
+ if !crate::is_nightly_channel!() {
+ return;
+ }
+ let toml = r#"
+ unstable_features = true
+ merge_imports = true
+ "#;
+ let mut config = Config::from_toml(toml, Path::new("")).unwrap();
+ config.override_value("imports_granularity", "Preserve");
+ assert_eq!(config.imports_granularity(), ImportGranularity::Preserve);
+ }
+
+ #[test]
+ fn test_old_overridden() {
+ if !crate::is_nightly_channel!() {
+ return;
+ }
+ let toml = r#"
+ unstable_features = true
+ imports_granularity = "Module"
+ "#;
+ let mut config = Config::from_toml(toml, Path::new("")).unwrap();
+ config.override_value("merge_imports", "true");
+ // no effect: the new option always takes precedence
+ assert_eq!(config.imports_granularity(), ImportGranularity::Module);
+ }
+ }