Skip to content

Commit

Permalink
Merge pull request #220 from dtolnay/toml
Browse files Browse the repository at this point in the history
Replace toml 0.5 -> basic-toml
  • Loading branch information
dtolnay authored Jan 27, 2023
2 parents 26518ef + 0e38544 commit 2f6d6dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --ignore toml --exit-code 1
- run: cargo outdated --workspace --exit-code 1
- run: cargo outdated --manifest-path fuzz/Cargo.toml --exit-code 1

fuzz:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ serde = "1.0.139"
serde_derive = "1.0.139"
serde_json = "1.0"
termcolor = "1.0.4"
toml = "0.5.2"
basic-toml = "0.1"

[lib]
doc-scrape-examples = false
Expand Down
6 changes: 3 additions & 3 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ use serde::de::value::StrDeserializer;
use serde::de::{self, Deserialize, Deserializer, Visitor};
use serde::ser::{Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::BTreeMap as Map;
use std::fmt;
use std::fs;
use std::path::PathBuf;
use toml::Value;

pub fn get_manifest(manifest_dir: &Directory) -> Result<Manifest, Error> {
let cargo_toml_path = manifest_dir.join("Cargo.toml");
let mut manifest = (|| {
let manifest_str = fs::read_to_string(&cargo_toml_path)?;
let manifest: Manifest = toml::from_str(&manifest_str)?;
let manifest: Manifest = basic_toml::from_str(&manifest_str)?;
Ok(manifest)
})()
.map_err(|err| Error::GetManifest(cargo_toml_path, Box::new(err)))?;
Expand All @@ -39,7 +39,7 @@ pub fn get_workspace_manifest(manifest_dir: &Directory) -> WorkspaceManifest {
pub fn try_get_workspace_manifest(manifest_dir: &Directory) -> Result<WorkspaceManifest, Error> {
let cargo_toml_path = manifest_dir.join("Cargo.toml");
let manifest_str = fs::read_to_string(cargo_toml_path)?;
let mut manifest: WorkspaceManifest = toml::from_str(&manifest_str)?;
let mut manifest: WorkspaceManifest = basic_toml::from_str(&manifest_str)?;

fix_dependencies(&mut manifest.workspace.dependencies, manifest_dir);
fix_patches(&mut manifest.patch, manifest_dir);
Expand Down
18 changes: 5 additions & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub enum Error {
ReadStderr(io::Error),
RunFailed,
ShouldNotHaveCompiled,
TomlDe(toml::de::Error),
TomlSer(toml::ser::Error),
Toml(basic_toml::Error),
UpdateVar(OsString),
WriteStderr(io::Error),
}
Expand Down Expand Up @@ -49,8 +48,7 @@ impl Display for Error {
ShouldNotHaveCompiled => {
write!(f, "expected test case to fail to compile, but it succeeded")
}
TomlDe(e) => write!(f, "{}", e),
TomlSer(e) => write!(f, "{}", e),
Toml(e) => write!(f, "{}", e),
UpdateVar(var) => write!(
f,
"unrecognized value of TRYBUILD: {:?}",
Expand Down Expand Up @@ -90,14 +88,8 @@ impl From<io::Error> for Error {
}
}

impl From<toml::de::Error> for Error {
fn from(err: toml::de::Error) -> Self {
Error::TomlDe(err)
}
}

impl From<toml::ser::Error> for Error {
fn from(err: toml::ser::Error) -> Self {
Error::TomlSer(err)
impl From<basic_toml::Error> for Error {
fn from(err: basic_toml::Error) -> Self {
Error::Toml(err)
}
}
4 changes: 2 additions & 2 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ impl Runner {
}

fn write(&self, project: &mut Project) -> Result<()> {
let manifest_toml = toml::to_string(&project.manifest)?;
let manifest_toml = basic_toml::to_string(&project.manifest)?;

let config = self.make_config();
let config_toml = toml::to_string(&config)?;
let config_toml = basic_toml::to_string(&config)?;

fs::create_dir_all(path!(project.dir / ".cargo"))?;
fs::write(path!(project.dir / ".cargo" / "config"), config_toml)?;
Expand Down

0 comments on commit 2f6d6dd

Please sign in to comment.