Skip to content

Commit e3eda30

Browse files
committed
refactor(config): Pull in toml parse wrapper
1 parent 8cf7143 commit e3eda30

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/cargo/util/config/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ use crate::sources::CRATES_IO_REGISTRY;
7676
use crate::util::errors::CargoResult;
7777
use crate::util::network::http::configure_http_handle;
7878
use crate::util::network::http::http_handle;
79-
use crate::util::toml as cargo_toml;
8079
use crate::util::{internal, CanonicalUrl};
8180
use crate::util::{try_canonicalize, validate_package_name};
8281
use crate::util::{Filesystem, IntoUrl, IntoUrlWithBase, Rustc};
@@ -1198,7 +1197,7 @@ impl Config {
11981197
}
11991198
let contents = fs::read_to_string(path)
12001199
.with_context(|| format!("failed to read configuration file `{}`", path.display()))?;
1201-
let toml = cargo_toml::parse_document(&contents, path, self).with_context(|| {
1200+
let toml = parse_document(&contents, path, self).with_context(|| {
12021201
format!("could not parse TOML configuration in `{}`", path.display())
12031202
})?;
12041203
let def = match why_load {
@@ -2249,7 +2248,7 @@ pub fn save_credentials(
22492248
)
22502249
})?;
22512250

2252-
let mut toml = cargo_toml::parse_document(&contents, file.path(), cfg)?;
2251+
let mut toml = parse_document(&contents, file.path(), cfg)?;
22532252

22542253
// Move the old token location to the new one.
22552254
if let Some(token) = toml.remove("token") {
@@ -2716,6 +2715,11 @@ impl EnvConfigValue {
27162715

27172716
pub type EnvConfig = HashMap<String, EnvConfigValue>;
27182717

2718+
fn parse_document(toml: &str, _file: &Path, _config: &Config) -> CargoResult<toml::Table> {
2719+
// At the moment, no compatibility checks are needed.
2720+
toml.parse().map_err(Into::into)
2721+
}
2722+
27192723
/// A type to deserialize a list of strings from a toml file.
27202724
///
27212725
/// Supports deserializing either a whitespace-separated list of arguments in a

src/cargo/util/toml/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ fn read_manifest_from_str(
175175
}
176176
}
177177

178-
pub fn parse_document(toml: &str, _file: &Path, _config: &Config) -> CargoResult<toml::Table> {
179-
// At the moment, no compatibility checks are needed.
180-
toml.parse().map_err(Into::into)
181-
}
182-
183178
/// Warn about paths that have been deprecated and may conflict.
184179
fn warn_on_deprecated(new_path: &str, name: &str, kind: &str, warnings: &mut Vec<String>) {
185180
let old_path = new_path.replace("-", "_");

0 commit comments

Comments
 (0)