diff --git a/Cargo.lock b/Cargo.lock index 3108ead728..019baceab5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2720,9 +2720,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" dependencies = [ "serde", "serde_spanned", diff --git a/src/cli/settings/set.rs b/src/cli/settings/set.rs index dcbe704d7e..ae7b2719a3 100644 --- a/src/cli/settings/set.rs +++ b/src/cli/settings/set.rs @@ -1,5 +1,5 @@ use eyre::Result; -use toml_edit::Document; +use toml_edit::DocumentMut; use crate::config::settings::SettingsFile; @@ -61,7 +61,7 @@ impl SettingsSet { let path = &*env::MISE_GLOBAL_CONFIG_FILE; file::create_dir_all(path.parent().unwrap())?; let raw = file::read_to_string(path).unwrap_or_default(); - let mut config: Document = raw.parse()?; + let mut config: DocumentMut = raw.parse()?; if !config.contains_key("settings") { config["settings"] = toml_edit::Item::Table(toml_edit::Table::new()); } diff --git a/src/cli/settings/unset.rs b/src/cli/settings/unset.rs index 574b52b865..f159f11c86 100644 --- a/src/cli/settings/unset.rs +++ b/src/cli/settings/unset.rs @@ -1,5 +1,5 @@ use eyre::Result; -use toml_edit::Document; +use toml_edit::DocumentMut; use crate::{env, file}; @@ -17,7 +17,7 @@ impl SettingsUnset { pub fn run(self) -> Result<()> { let path = env::MISE_CONFIG_DIR.join("config.toml"); let raw = file::read_to_string(&path)?; - let mut settings: Document = raw.parse()?; + let mut settings: DocumentMut = raw.parse()?; settings.remove(&self.setting); file::write(&path, settings.to_string()) } diff --git a/src/config/config_file/mise_toml.rs b/src/config/config_file/mise_toml.rs index a0a8651569..28849335b1 100644 --- a/src/config/config_file/mise_toml.rs +++ b/src/config/config_file/mise_toml.rs @@ -10,7 +10,7 @@ use serde::de::Visitor; use serde::{de, Deserializer}; use serde_derive::Deserialize; use tera::Context as TeraContext; -use toml_edit::{table, value, Array, Document, Item, Value}; +use toml_edit::{table, value, Array, DocumentMut, Item, Value}; use versions::Versioning; use crate::cli::args::{ForgeArg, ToolVersionType}; @@ -43,7 +43,7 @@ pub struct MiseToml { #[serde(default, deserialize_with = "deserialize_alias")] alias: AliasMap, #[serde(skip)] - doc: OnceCell, + doc: OnceCell, #[serde(default)] tools: IndexMap, #[serde(default)] @@ -97,14 +97,14 @@ impl MiseToml { Ok(rf) } - fn doc(&self) -> eyre::Result<&Document> { + fn doc(&self) -> eyre::Result<&DocumentMut> { self.doc.get_or_try_init(|| { let body = file::read_to_string(&self.path).unwrap_or_default(); Ok(body.parse()?) }) } - fn doc_mut(&mut self) -> eyre::Result<&mut Document> { + fn doc_mut(&mut self) -> eyre::Result<&mut DocumentMut> { self.doc()?; Ok(self.doc.get_mut().unwrap()) } @@ -640,6 +640,17 @@ impl<'de> de::Deserialize<'de> for MiseTomlToolList { }])) } + fn visit_seq(self, mut seq: S) -> std::result::Result + where + S: de::SeqAccess<'de>, + { + let mut tools = vec![]; + while let Some(tool) = seq.next_element::()? { + tools.push(tool); + } + Ok(MiseTomlToolList(tools)) + } + fn visit_map(self, map: M) -> std::result::Result where M: de::MapAccess<'de>, @@ -656,17 +667,6 @@ impl<'de> de::Deserialize<'de> for MiseTomlToolList { .map_err(de::Error::custom)?; Ok(MiseTomlToolList(vec![MiseTomlTool { tt, options }])) } - - fn visit_seq(self, mut seq: S) -> std::result::Result - where - S: de::SeqAccess<'de>, - { - let mut tools = vec![]; - while let Some(tool) = seq.next_element::()? { - tools.push(tool); - } - Ok(MiseTomlToolList(tools)) - } } deserializer.deserialize_any(MiseTomlToolListVisitor) diff --git a/src/plugins/mise_plugin_toml.rs b/src/plugins/mise_plugin_toml.rs index fc9a592c01..ed36ca3db2 100644 --- a/src/plugins/mise_plugin_toml.rs +++ b/src/plugins/mise_plugin_toml.rs @@ -2,7 +2,7 @@ use std::path::Path; use color_eyre::eyre::eyre; use color_eyre::{Result, Section}; -use toml_edit::{Document, Item, Value}; +use toml_edit::{DocumentMut, Item, Value}; use crate::{file, parse_error}; @@ -39,7 +39,7 @@ impl MisePluginToml { } fn parse(&mut self, s: &str) -> Result<()> { - let doc: Document = s.parse().suggestion("ensure file is valid TOML")?; + let doc: DocumentMut = s.parse().suggestion("ensure file is valid TOML")?; for (k, v) in doc.iter() { match k { "exec-env" => self.exec_env = self.parse_script_config(k, v)?,