Skip to content

Commit ecca268

Browse files
committed
refactor(gctx): remove unnecessary utf8 conversion
1 parent 6c1b610 commit ecca268

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/cargo/util/context/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,14 +1447,10 @@ impl GlobalContext {
14471447
let arg_as_path = self.cwd.join(arg);
14481448
let tmp_table = if !arg.is_empty() && arg_as_path.exists() {
14491449
// --config path_to_file
1450-
let str_path = arg_as_path
1451-
.to_str()
1452-
.ok_or_else(|| {
1453-
anyhow::format_err!("config path {:?} is not utf-8", arg_as_path)
1450+
self._load_file(&arg_as_path, &mut seen, true, WhyLoad::Cli)
1451+
.with_context(|| {
1452+
format!("failed to load config from `{}`", arg_as_path.display())
14541453
})?
1455-
.to_string();
1456-
self._load_file(&self.cwd().join(&str_path), &mut seen, true, WhyLoad::Cli)
1457-
.with_context(|| format!("failed to load config from `{}`", str_path))?
14581454
} else {
14591455
let doc = toml_dotted_keys(arg)?;
14601456
let doc: toml::Value = toml::Value::deserialize(doc.into_deserializer())

0 commit comments

Comments
 (0)