Skip to content

Commit

Permalink
Drop basic-toml in favor of more widely used toml crate
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 16, 2024
1 parent e8dfc24 commit acb76ef
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable, 1.56.0]
rust: [nightly, beta, stable, 1.70.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ rust-version = "1.56"
diff = ["dissimilar"]

[dependencies]
basic-toml = "0.1.8"
dissimilar = { version = "1.0", optional = true }
glob = "0.3"
once_cell = "1.9"
serde = "1.0.194"
serde_derive = "1.0.194"
serde_json = "1.0.110"
termcolor = "1.0.4"
toml = "0.8"

[dev-dependencies]
automod = "1.0.10"
Expand Down
4 changes: 2 additions & 2 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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 = basic_toml::from_str(&manifest_str)?;
let manifest: Manifest = 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 = basic_toml::from_str(&manifest_str)?;
let mut manifest: WorkspaceManifest = toml::from_str(&manifest_str)?;

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

impl From<basic_toml::Error> for Error {
fn from(err: basic_toml::Error) -> Self {
Error::Toml(err)
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)
}
}
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 = basic_toml::to_string(&project.manifest)?;
let manifest_toml = toml::to_string(&project.manifest)?;

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

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

0 comments on commit acb76ef

Please sign in to comment.