Skip to content

Commit fb88c80

Browse files
committed
Better name for ConfigError
1 parent 1cf2446 commit fb88c80

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/config.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::toolchain::{DistributableToolchain, Toolchain, UpdateStatus};
2525
use crate::utils::utils;
2626

2727
#[derive(Debug, ThisError)]
28-
enum ConfigError {
28+
enum OverrideFileConfigError {
2929
#[error("empty toolchain override file detected. Please remove it, or else specify the desired toolchain properties in the file")]
3030
Empty,
3131
#[error("missing toolchain properties in toolchain override file")]
@@ -677,22 +677,22 @@ impl Cfg {
677677
let contents = contents.as_ref();
678678

679679
match (contents.lines().count(), parse_mode) {
680-
(0, _) => Err(anyhow!(ConfigError::Empty)),
680+
(0, _) => Err(anyhow!(OverrideFileConfigError::Empty)),
681681
(1, ParseMode::Both) => {
682682
let channel = contents.trim();
683683

684684
if channel.is_empty() {
685-
Err(anyhow!(ConfigError::Empty))
685+
Err(anyhow!(OverrideFileConfigError::Empty))
686686
} else {
687687
Ok(channel.into())
688688
}
689689
}
690690
_ => {
691-
let override_file =
692-
toml::from_str::<OverrideFile>(contents).context(ConfigError::Parsing)?;
691+
let override_file = toml::from_str::<OverrideFile>(contents)
692+
.context(OverrideFileConfigError::Parsing)?;
693693

694694
if override_file.is_empty() {
695-
Err(anyhow!(ConfigError::Invalid))
695+
Err(anyhow!(OverrideFileConfigError::Invalid))
696696
} else {
697697
Ok(override_file)
698698
}
@@ -1162,8 +1162,8 @@ components = [ "rustfmt" ]
11621162

11631163
let result = Cfg::parse_override_file(contents, ParseMode::Both);
11641164
assert!(matches!(
1165-
result.unwrap_err().downcast::<ConfigError>(),
1166-
Ok(ConfigError::Invalid)
1165+
result.unwrap_err().downcast::<OverrideFileConfigError>(),
1166+
Ok(OverrideFileConfigError::Invalid)
11671167
));
11681168
}
11691169

@@ -1173,8 +1173,8 @@ components = [ "rustfmt" ]
11731173

11741174
let result = Cfg::parse_override_file(contents, ParseMode::Both);
11751175
assert!(matches!(
1176-
result.unwrap_err().downcast::<ConfigError>(),
1177-
Ok(ConfigError::Empty)
1176+
result.unwrap_err().downcast::<OverrideFileConfigError>(),
1177+
Ok(OverrideFileConfigError::Empty)
11781178
));
11791179
}
11801180

@@ -1184,8 +1184,8 @@ components = [ "rustfmt" ]
11841184

11851185
let result = Cfg::parse_override_file(contents, ParseMode::Both);
11861186
assert!(matches!(
1187-
result.unwrap_err().downcast::<ConfigError>(),
1188-
Ok(ConfigError::Empty)
1187+
result.unwrap_err().downcast::<OverrideFileConfigError>(),
1188+
Ok(OverrideFileConfigError::Empty)
11891189
));
11901190
}
11911191

@@ -1197,8 +1197,8 @@ channel = nightly
11971197

11981198
let result = Cfg::parse_override_file(contents, ParseMode::Both);
11991199
assert!(matches!(
1200-
result.unwrap_err().downcast::<ConfigError>(),
1201-
Ok(ConfigError::Parsing)
1200+
result.unwrap_err().downcast::<OverrideFileConfigError>(),
1201+
Ok(OverrideFileConfigError::Parsing)
12021202
));
12031203
}
12041204
}

0 commit comments

Comments
 (0)