diff --git a/src/project/manifest/error.rs b/src/project/manifest/error.rs index da8a077bf..d1005c6d0 100644 --- a/src/project/manifest/error.rs +++ b/src/project/manifest/error.rs @@ -75,7 +75,7 @@ pub enum RequirementConversionError { #[derive(Error, Debug, Clone)] pub enum TomlError { #[error("{0}")] - Error(toml_edit::TomlError), + Error(#[from] toml_edit::TomlError), #[error("Missing field `project`")] NoProjectTable, #[error("Missing field `name`")] @@ -95,11 +95,11 @@ impl TomlError { } } - fn span(self) -> Option> { + fn span(&self) -> Option> { match self { TomlError::Error(e) => e.span(), TomlError::NoProjectTable => Some(0..1), - TomlError::NoProjectName(span) => span, + TomlError::NoProjectName(span) => span.clone(), } } fn message(&self) -> &str { @@ -115,8 +115,3 @@ impl From for TomlError { TomlError::Error(e.into()) } } -impl From for TomlError { - fn from(e: toml_edit::TomlError) -> Self { - TomlError::Error(e) - } -}