From 26319f41244fc3c8015addb3955bbd006b757c76 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 25 Jul 2025 13:24:19 -0700 Subject: [PATCH] Update toml to 0.9.2 --- Cargo.lock | 71 +++++++++++++++++++++++- Cargo.toml | 2 +- crates/mdbook-core/src/utils/toml_ext.rs | 9 ++- crates/mdbook-driver/src/init.rs | 9 ++- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d692f39..d89f15ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -582,6 +582,12 @@ dependencies = [ "log", ] +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + [[package]] name = "errno" version = "0.3.13" @@ -765,6 +771,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" + [[package]] name = "hex" version = "0.4.3" @@ -1045,6 +1057,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "inotify" version = "0.11.0" @@ -2047,6 +2069,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2354,13 +2385,43 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "ed0aee96c12fa71097902e0bb061a5e1ebd766a6636bb605ba401c45c1650eac" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" dependencies = [ "serde", ] +[[package]] +name = "toml_parser" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" + [[package]] name = "topological-sort" version = "0.2.2" @@ -2847,6 +2908,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" + [[package]] name = "wit-bindgen-rt" version = "0.39.0" diff --git a/Cargo.toml b/Cargo.toml index 3a8b5a8e..f027a20a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ shlex = "1.3.0" snapbox = "0.6.21" tempfile = "3.20.0" tokio = "1.46.1" -toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037 +toml = "0.9.2" topological-sort = "0.2.2" tower-http = "0.6.6" walkdir = "2.5.0" diff --git a/crates/mdbook-core/src/utils/toml_ext.rs b/crates/mdbook-core/src/utils/toml_ext.rs index 51ed8435..9bc1df47 100644 --- a/crates/mdbook-core/src/utils/toml_ext.rs +++ b/crates/mdbook-core/src/utils/toml_ext.rs @@ -62,12 +62,11 @@ fn split(key: &str) -> Option<(&str, &str)> { #[cfg(test)] mod tests { use super::*; - use std::str::FromStr; #[test] fn read_simple_table() { let src = "[table]"; - let value = Value::from_str(src).unwrap(); + let value: Value = toml::from_str(src).unwrap(); let got = value.read("table").unwrap(); @@ -77,7 +76,7 @@ mod tests { #[test] fn read_nested_item() { let src = "[table]\nnested=true"; - let value = Value::from_str(src).unwrap(); + let value: Value = toml::from_str(src).unwrap(); let got = value.read("table.nested").unwrap(); @@ -108,7 +107,7 @@ mod tests { #[test] fn delete_a_top_level_item() { let src = "top = true"; - let mut value = Value::from_str(src).unwrap(); + let mut value: Value = toml::from_str(src).unwrap(); let got = value.delete("top").unwrap(); @@ -118,7 +117,7 @@ mod tests { #[test] fn delete_a_nested_item() { let src = "[table]\n nested = true"; - let mut value = Value::from_str(src).unwrap(); + let mut value: Value = toml::from_str(src).unwrap(); let got = value.delete("table.nested").unwrap(); diff --git a/crates/mdbook-driver/src/init.rs b/crates/mdbook-driver/src/init.rs index ec62ce27..df5945ca 100644 --- a/crates/mdbook-driver/src/init.rs +++ b/crates/mdbook-driver/src/init.rs @@ -101,12 +101,11 @@ impl BookBuilder { fn write_book_toml(&self) -> Result<()> { debug!("Writing book.toml"); let book_toml = self.root.join("book.toml"); - let cfg = toml::to_vec(&self.config).with_context(|| "Unable to serialize the config")?; + let cfg = + toml::to_string(&self.config).with_context(|| "Unable to serialize the config")?; - File::create(book_toml) - .with_context(|| "Couldn't create book.toml")? - .write_all(&cfg) - .with_context(|| "Unable to write config to book.toml")?; + std::fs::write(&book_toml, cfg) + .with_context(|| format!("Unable to write config to {book_toml:?}"))?; Ok(()) }