From 2cf9008cb89d68084b47255f9850f8fc0e2b42b3 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sat, 4 Feb 2023 16:11:29 -0500 Subject: [PATCH] refactor: remove toml incompatibility hacks --- src/settings/file.rs | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/settings/file.rs b/src/settings/file.rs index 682573a..1418e8f 100644 --- a/src/settings/file.rs +++ b/src/settings/file.rs @@ -189,29 +189,7 @@ fn read_toml_file(path: &Path) -> Result { path.display() ) })?; - - let first_error = match toml_str.parse() { - Ok(res) => return Ok(res), - Err(err) => err, - }; - - let mut second_parser = toml::de::Deserializer::new(&toml_str); - second_parser.set_require_newline_after_table(false); - if let Ok(res) = toml::Value::deserialize(&mut second_parser) { - let msg = format!( - "\ -TOML file found which contains invalid syntax and will soon not parse -at `{}`. -The TOML spec requires newlines after table definitions (e.g., `[a] b = 1` is -invalid), but this file has a table header which does not have a newline after -it. A newline needs to be added and this warning will soon become a hard error -in the future.", - path.display() - ); - println!("{}", &msg); - return Ok(res); - } - - let first_error = anyhow::Error::from(first_error); - Err(first_error.context("could not parse data input as toml format")) + toml_str + .parse() + .map_err(|e| anyhow::Error::from(e).context("could not parse input as TOML")) } -- libgit2 1.7.2