Skip to content

Commit c4151a5

Browse files
authored
Replace toml with basic-toml (eupn#93)
1 parent 37da8da commit c4151a5

File tree

5 files changed

+21
-29
lines changed

5 files changed

+21
-29
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ repository = "https://github.com/eupn/macrotest"
1010
description = "Test harness for macro expansion"
1111

1212
[dependencies]
13+
basic-toml = "0.1"
1314
diff = "0.1"
1415
glob = "0.3"
1516
prettyplease = "0.2"
1617
serde = { version = "1.0.105", features = ["derive"] }
1718
serde_json = "1.0"
1819
syn = { version = "2", features = ["full"] }
19-
toml = "0.5"

src/dependencies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use crate::manifest::Edition;
33
use serde::de::value::MapAccessDeserializer;
44
use serde::de::{self, Visitor};
55
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
use serde_json::Value;
67
use std::collections::BTreeMap as Map;
78
use std::fmt;
89
use std::fs;
910
use std::path::Path;
1011
use std::path::PathBuf;
11-
use toml::Value;
1212

1313
pub(crate) fn get_manifest(manifest_dir: &Path) -> Manifest {
1414
try_get_manifest(manifest_dir).unwrap_or_default()
@@ -17,7 +17,7 @@ pub(crate) fn get_manifest(manifest_dir: &Path) -> Manifest {
1717
fn try_get_manifest(manifest_dir: &Path) -> Result<Manifest, Error> {
1818
let cargo_toml_path = manifest_dir.join("Cargo.toml");
1919
let manifest_str = fs::read_to_string(cargo_toml_path)?;
20-
let mut manifest: Manifest = toml::from_str(&manifest_str)?;
20+
let mut manifest: Manifest = basic_toml::from_str(&manifest_str)?;
2121

2222
fix_dependencies(&mut manifest.dependencies, manifest_dir);
2323
fix_dependencies(&mut manifest.dev_dependencies, manifest_dir);
@@ -32,7 +32,7 @@ pub(crate) fn get_workspace_manifest(manifest_dir: &Path) -> WorkspaceManifest {
3232
pub(crate) fn try_get_workspace_manifest(manifest_dir: &Path) -> Result<WorkspaceManifest, Error> {
3333
let cargo_toml_path = manifest_dir.join("Cargo.toml");
3434
let manifest_str = fs::read_to_string(cargo_toml_path)?;
35-
let mut manifest: WorkspaceManifest = toml::from_str(&manifest_str)?;
35+
let mut manifest: WorkspaceManifest = basic_toml::from_str(&manifest_str)?;
3636

3737
fix_patches(&mut manifest.patch, manifest_dir);
3838
fix_replacements(&mut manifest.replace, manifest_dir);

src/error.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ pub(crate) enum Error {
77
CargoFail,
88
CargoMetadata(serde_json::error::Error),
99
IoError(std::io::Error),
10-
TomlSerError(toml::ser::Error),
11-
TomlDeError(toml::de::Error),
10+
TomlError(basic_toml::Error),
1211
GlobError(glob::GlobError),
1312
GlobPatternError(glob::PatternError),
1413
ManifestDirError,
@@ -28,8 +27,7 @@ impl std::fmt::Display for Error {
2827
CargoFail => write!(f, "cargo reported an error"),
2928
CargoMetadata(e) => write!(f, "{}", e),
3029
IoError(e) => write!(f, "{}", e),
31-
TomlSerError(e) => write!(f, "{}", e),
32-
TomlDeError(e) => write!(f, "{}", e),
30+
TomlError(e) => write!(f, "{}", e),
3331
GlobError(e) => write!(f, "{}", e),
3432
GlobPatternError(e) => write!(f, "{}", e),
3533
ManifestDirError => write!(f, "could not find CARGO_MANIFEST_DIR env var"),
@@ -49,15 +47,9 @@ impl From<std::io::Error> for Error {
4947
}
5048
}
5149

52-
impl From<toml::ser::Error> for Error {
53-
fn from(e: toml::ser::Error) -> Self {
54-
Error::TomlSerError(e)
55-
}
56-
}
57-
58-
impl From<toml::de::Error> for Error {
59-
fn from(e: toml::de::Error) -> Self {
60-
Error::TomlDeError(e)
50+
impl From<basic_toml::Error> for Error {
51+
fn from(e: basic_toml::Error) -> Self {
52+
Error::TomlError(e)
6153
}
6254
}
6355

src/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ fn prepare(tests: &[ExpandedTest]) -> Result<Project> {
216216
};
217217

218218
let manifest = make_manifest(crate_name, &project, tests)?;
219-
let manifest_toml = toml::to_string(&manifest)?;
219+
let manifest_toml = basic_toml::to_string(&manifest)?;
220220

221221
let config = make_config();
222-
let config_toml = toml::to_string(&config)?;
222+
let config_toml = basic_toml::to_string(&config)?;
223223

224224
if let Some(enabled_features) = &mut project.features {
225225
enabled_features.retain(|feature| manifest.features.contains_key(feature));

test-project/Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)