Skip to content

Commit a5939f3

Browse files
authored
Merge pull request #52 from bkchr/bkchr-upgrade-toml-edit
Upgrade all dependencies
2 parents 444cbcc + 3100858 commit a5939f3

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "proc-macro-crate"
3-
version = "3.1.0"
3+
version = "3.2.0"
44
authors = ["Bastian Köcher <[email protected]>"]
55
edition = "2021"
66
categories = ["development-tools::procedural-macro-helpers"]
@@ -15,9 +15,9 @@ readme = "./README.md"
1515
rust-version = "1.67.0"
1616

1717
[dependencies]
18-
toml_edit = "0.21.0"
18+
toml_edit = "0.22.20"
1919

2020
[dev-dependencies]
21-
quote = "1.0.33"
22-
syn = "2.0.37"
23-
proc-macro2 = "1.0.67"
21+
quote = "1.0.37"
22+
syn = "2.0.76"
23+
proc-macro2 = "1.0.86"

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use std::{
9494
time::SystemTime,
9595
};
9696

97-
use toml_edit::{Document, Item, Table, TomlError};
97+
use toml_edit::{DocumentMut, Item, Table, TomlError};
9898

9999
/// Error type used by this crate.
100100
pub enum Error {
@@ -302,7 +302,7 @@ fn read_cargo_toml(
302302
/// Returns a hash map that maps from dep name to the package name. Dep name
303303
/// and package name can be the same if there doesn't exist any rename.
304304
fn extract_workspace_dependencies(
305-
workspace_toml: &Document,
305+
workspace_toml: &DocumentMut,
306306
) -> Result<BTreeMap<String, String>, Error> {
307307
Ok(workspace_dep_tables(&workspace_toml)
308308
.into_iter()
@@ -316,7 +316,7 @@ fn extract_workspace_dependencies(
316316
}
317317

318318
/// Return an iterator over all `[workspace.dependencies]`
319-
fn workspace_dep_tables(cargo_toml: &Document) -> Option<&Table> {
319+
fn workspace_dep_tables(cargo_toml: &DocumentMut) -> Option<&Table> {
320320
cargo_toml
321321
.get("workspace")
322322
.and_then(|w| w.as_table()?.get("dependencies")?.as_table())
@@ -328,16 +328,16 @@ fn sanitize_crate_name<S: AsRef<str>>(name: S) -> String {
328328
}
329329

330330
/// Open the given `Cargo.toml` and parse it into a hashmap.
331-
fn open_cargo_toml(path: &Path) -> Result<Document, Error> {
331+
fn open_cargo_toml(path: &Path) -> Result<DocumentMut, Error> {
332332
let content = fs::read_to_string(path)
333333
.map_err(|e| Error::CouldNotRead { source: e, path: path.into() })?;
334-
content.parse::<Document>().map_err(|e| Error::InvalidToml { source: e })
334+
content.parse::<DocumentMut>().map_err(|e| Error::InvalidToml { source: e })
335335
}
336336

337337
/// Extract all crate names from the given `Cargo.toml` by checking the `dependencies` and
338338
/// `dev-dependencies`.
339339
fn extract_crate_names(
340-
cargo_toml: &Document,
340+
cargo_toml: &DocumentMut,
341341
workspace_dependencies: BTreeMap<String, String>,
342342
) -> Result<CrateNames, Error> {
343343
let package_name = extract_package_name(cargo_toml);
@@ -377,11 +377,11 @@ fn extract_crate_names(
377377
Ok(root_pkg.into_iter().chain(dep_pkgs).collect())
378378
}
379379

380-
fn extract_package_name(cargo_toml: &Document) -> Option<&str> {
380+
fn extract_package_name(cargo_toml: &DocumentMut) -> Option<&str> {
381381
cargo_toml.get("package")?.get("name")?.as_str()
382382
}
383383

384-
fn target_dep_tables(cargo_toml: &Document) -> impl Iterator<Item = &Table> {
384+
fn target_dep_tables(cargo_toml: &DocumentMut) -> impl Iterator<Item = &Table> {
385385
cargo_toml.get("target").into_iter().filter_map(Item::as_table).flat_map(|t| {
386386
t.iter().map(|(_, value)| value).filter_map(Item::as_table).flat_map(dep_tables)
387387
})
@@ -408,9 +408,9 @@ mod tests {
408408
) => {
409409
#[test]
410410
fn $name() {
411-
let cargo_toml = $cargo_toml.parse::<Document>()
411+
let cargo_toml = $cargo_toml.parse::<DocumentMut>()
412412
.expect("Parses `Cargo.toml`");
413-
let workspace_cargo_toml = $workspace_toml.parse::<Document>()
413+
let workspace_cargo_toml = $workspace_toml.parse::<DocumentMut>()
414414
.expect("Parses workspace `Cargo.toml`");
415415

416416
let workspace_deps = extract_workspace_dependencies(&workspace_cargo_toml)

0 commit comments

Comments
 (0)