diff --git a/crates/toml/src/macros.rs b/crates/toml/src/macros.rs index 19b2ce22..d86cc52f 100644 --- a/crates/toml/src/macros.rs +++ b/crates/toml/src/macros.rs @@ -2,9 +2,7 @@ pub use serde::de::{Deserialize, IntoDeserializer}; use crate::value::{Array, Table, Value}; -/// Construct a [`toml::Value`] from TOML syntax. -/// -/// [`toml::Value`]: value/enum.Value.html +/// Construct a [`Table`] from TOML syntax. /// /// ```rust /// let cargo_toml = toml::toml! { @@ -32,7 +30,10 @@ macro_rules! toml { let table = $crate::value::Table::new(); let mut root = $crate::Value::Table(table); $crate::toml_internal!(@toplevel root [] $($toml)+); - root + match root { + $crate::Value::Table(table) => table, + _ => unreachable!(), + } }}; } diff --git a/crates/toml/tests/testsuite/macros.rs b/crates/toml/tests/testsuite/macros.rs index 76fb2df5..51007051 100644 --- a/crates/toml/tests/testsuite/macros.rs +++ b/crates/toml/tests/testsuite/macros.rs @@ -82,7 +82,7 @@ fn test_cargo_toml() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } #[test] @@ -137,7 +137,7 @@ fn test_array() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } #[test] @@ -188,7 +188,7 @@ fn test_number() { "bin" => 214, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } #[test] @@ -278,7 +278,7 @@ fn test_datetime() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } // This test requires rustc >= 1.20. @@ -306,7 +306,7 @@ fn test_quoted_key() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } #[test] @@ -329,7 +329,7 @@ fn test_empty() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); } #[test] @@ -364,5 +364,5 @@ fn test_dotted_keys() { }, }; - assert_eq!(actual, expected); + assert_eq!(toml::Value::Table(actual), expected); }