From 1996c1a611386003532f791f60aed46c3562bc3d Mon Sep 17 00:00:00 2001 From: Chance Date: Wed, 29 Jan 2025 23:21:40 -0500 Subject: [PATCH] resolves duplication of errors in miette --- src/assign.rs | 128 +++++++++------------------------------------- src/diagnostic.rs | 32 +++++++++--- src/index.rs | 14 ++--- src/pointer.rs | 79 +++++++++------------------- src/resolve.rs | 91 +++++++++++--------------------- src/token.rs | 2 +- 6 files changed, 112 insertions(+), 234 deletions(-) diff --git a/src/assign.rs b/src/assign.rs index 377d7af..d173ad9 100644 --- a/src/assign.rs +++ b/src/assign.rs @@ -37,7 +37,7 @@ //! use crate::{ - diagnostic::{impl_diagnostic_url, Diagnostic, Label}, + diagnostic::{diagnostic_url, Diagnostic, Label}, index::{OutOfBoundsError, ParseIndexError}, Pointer, PointerBuf, }; @@ -47,16 +47,6 @@ use core::{ iter::once, }; -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Assign ║ -║ ¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// Implemented by types which can internally assign a /// ([`Value`](`Assign::Value`)) at a path represented by a JSON [`Pointer`]. /// @@ -134,30 +124,10 @@ pub trait Assign { V: Into; } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ AssignError ║ -║ ¯¯¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// Alias for [`Error`] - indicates a value assignment failed. #[deprecated(since = "0.7.0", note = "renamed to `Error`")] pub type AssignError = Error; -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Error ║ -║ ¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// Possible error returned from [`Assign`] implementations for /// [`serde_json::Value`] and /// [`toml::Value`](https://docs.rs/toml/0.8.14/toml/index.html). @@ -207,24 +177,12 @@ impl Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::FailedToParseIndex { .. } => { - write!( - f, - "value failed to be assigned by json pointer; \ - array index for token at offset {} is not a valid integer or '-'", - self.offset() - ) - } - Self::OutOfBounds { .. } => { - write!( - f, - "value failed to be assigned by json pointer; \ - array index for token at offset {} is out of bounds", - self.offset() - ) - } - } + write!( + f, + "value failed to be assigned, caused by token (position: {}, offset: {}) of the json pointer", + self.position(), + self.offset() + ) } } @@ -232,7 +190,7 @@ impl Diagnostic for Error { type Subject = PointerBuf; fn url() -> &'static str { - impl_diagnostic_url!(enum assign::Error) + diagnostic_url!(enum assign::Error) } fn labels(&self, origin: &Self::Subject) -> Option>> { @@ -244,18 +202,22 @@ impl Diagnostic for Error { self.offset() }; let len = token.encoded().len(); - Some(match self { - Error::FailedToParseIndex { .. } => Box::new(once(Label::new( - format!("\"{}\" is an invalid array index", token.decoded()), - offset, - len, - ))), - Error::OutOfBounds { source, .. } => Box::new(once(Label::new( - format!("{} is out of bounds (len: {})", source.index, source.length), - offset, - len, - ))), - }) + let text = match self { + Error::FailedToParseIndex { .. } => { + format!("expected array index or '-', found \"{}\"", token.decoded()) + } + Error::OutOfBounds { source, .. } => { + format!("{} is out of bounds (len: {})", source.index, source.length) + } + }; + Some(Box::new(once(Label::new(text, offset, len)))) + } +} + +#[cfg(feature = "miette")] +impl miette::Diagnostic for Error { + fn url<'a>(&'a self) -> Option> { + Some(Box::new(::url())) } } @@ -269,16 +231,6 @@ impl std::error::Error for Error { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ json impl ║ -║ ¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(feature = "json")] mod json { use super::{Assign, Assigned, Error}; @@ -454,16 +406,6 @@ mod json { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ toml impl ║ -║ ¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(feature = "toml")] mod toml { use super::{Assign, Assigned, Error}; @@ -638,16 +580,6 @@ enum Assigned<'v, V> { Continue { next_dest: &'v mut V, same_value: V }, } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Tests ║ -║ ¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(test)] #[allow(clippy::too_many_lines)] mod tests { @@ -694,12 +626,6 @@ mod tests { } } - /* - ╔═══════════════════════════════════════════════════╗ - ║ json ║ - ╚═══════════════════════════════════════════════════╝ - */ - #[test] #[cfg(feature = "json")] fn assign_json() { @@ -890,12 +816,6 @@ mod tests { .for_each(|(i, t)| t.run(i)); } - /* - ╔══════════════════════════════════════════════════╗ - ║ toml ║ - ╚══════════════════════════════════════════════════╝ - */ - #[test] #[cfg(feature = "toml")] fn assign_toml() { diff --git a/src/diagnostic.rs b/src/diagnostic.rs index be9a505..e450e77 100644 --- a/src/diagnostic.rs +++ b/src/diagnostic.rs @@ -93,7 +93,7 @@ where D::Subject: fmt::Debug, { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(&self.source) + self.source.source() } } @@ -116,18 +116,18 @@ where } } -macro_rules! impl_diagnostic_url { +macro_rules! diagnostic_url { (enum $type:ident) => { - $crate::diagnostic::impl_diagnostic_url!("enum", "", $type) + $crate::diagnostic::diagnostic_url!("enum", "", $type) }; (struct $type:ident) => { - $crate::diagnostic::impl_diagnostic_url!("struct", "", $type) + $crate::diagnostic::diagnostic_url!("struct", "", $type) }; (enum $mod:ident::$type:ident) => { - $crate::diagnostic::impl_diagnostic_url!("enum", concat!("/", stringify!($mod)), $type) + $crate::diagnostic::diagnostic_url!("enum", concat!("/", stringify!($mod)), $type) }; (struct $mod:ident::$type:ident) => { - $crate::diagnostic::impl_diagnostic_url!("struct", concat!("/", stringify!($mod)), $type) + $crate::diagnostic::diagnostic_url!("struct", concat!("/", stringify!($mod)), $type) }; ($kind:literal, $mod:expr, $type:ident) => { concat!( @@ -143,7 +143,7 @@ macro_rules! impl_diagnostic_url { ) }; } -pub(crate) use impl_diagnostic_url; +pub(crate) use diagnostic_url; /// An extension trait for `Result<_, E>`, where `E` is an implementation of /// [`Diagnostic`], that converts `E` into [`Report`](`Report`), yielding @@ -231,6 +231,24 @@ mod tests { println!("{:?}", miette::Report::from(report)); } + #[test] + #[cfg(all( + feature = "resolve", + feature = "miette", + feature = "serde", + feature = "json" + ))] + fn resolve_error() { + let v = serde_json::json!({"foo": {"bar": ["0"]}}); + let ptr = PointerBuf::parse("/foo/bar/invalid/cannot/reach").unwrap(); + let report = ptr.resolve(&v).diagnose(ptr).unwrap_err(); + println!("{:?}", miette::Report::from(report)); + + let ptr = PointerBuf::parse("/foo/bar/3/cannot/reach").unwrap(); + let report = ptr.resolve(&v).diagnose(ptr).unwrap_err(); + println!("{:?}", miette::Report::from(report)); + } + #[test] fn parse_error() { let invalid = "/foo/bar/invalid~3~encoding/cannot/reach"; diff --git a/src/index.rs b/src/index.rs index 0acbb4b..e5905e3 100644 --- a/src/index.rs +++ b/src/index.rs @@ -237,7 +237,7 @@ derive_try_from!(String, &String); */ /// Indicates that an `Index` is not within the given bounds. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct OutOfBoundsError { /// The provided array length. /// @@ -276,7 +276,7 @@ impl std::error::Error for OutOfBoundsError {} */ /// Indicates that the `Token` could not be parsed as valid RFC 6901 array index. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum ParseIndexError { /// The Token does not represent a valid integer. InvalidInteger(ParseIntError), @@ -295,14 +295,16 @@ impl From for ParseIndexError { impl fmt::Display for ParseIndexError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ParseIndexError::InvalidInteger(source) => { - write!(f, "failed to parse token as an integer: {source}") + ParseIndexError::InvalidInteger(_) => { + write!(f, "failed to parse token as an integer") } ParseIndexError::LeadingZeros => write!( f, "token contained leading zeros, which are disallowed by RFC 6901" ), - ParseIndexError::InvalidCharacter(err) => err.fmt(f), + ParseIndexError::InvalidCharacter(_) => { + write!(f, "failed to parse token as an index") + } } } } @@ -319,7 +321,7 @@ impl std::error::Error for ParseIndexError { } /// Indicates that a non-digit character was found when parsing the RFC 6901 array index. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct InvalidCharacterError { pub(crate) source: String, pub(crate) offset: usize, diff --git a/src/pointer.rs b/src/pointer.rs index 99b0512..4cca2f4 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -1,5 +1,5 @@ use crate::{ - diagnostic::{impl_diagnostic_url, Diagnostic, Label, Report}, + diagnostic::{diagnostic_url, Diagnostic, Label, Report}, token::EncodingError, Components, InvalidEncoding, Token, Tokens, }; @@ -15,16 +15,6 @@ use slice::PointerIndex; mod slice; -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Pointer ║ -║ ¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// A JSON Pointer is a string containing a sequence of zero or more reference /// [`Token`]s, each prefixed by a `'/'` character. /// @@ -898,16 +888,6 @@ impl<'a> IntoIterator for &'a Pointer { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ PointerBuf ║ -║ ¯¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// An owned, mutable [`Pointer`] (akin to `String`). /// /// This type provides methods like [`PointerBuf::push_back`] and @@ -1169,15 +1149,19 @@ impl core::fmt::Display for PointerBuf { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ ParseError ║ -║ ¯¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ +/// Indicates that a [`Pointer`] was unable to be parsed due to not containing +/// a leading slash (`'/'`). +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub struct NoLeadingSlash; + +impl fmt::Display for NoLeadingSlash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "json pointer must start with a backslash ('/') and is not empty" + ) + } +} /// Indicates that a `Pointer` was malformed and unable to be parsed. #[derive(Debug, PartialEq)] @@ -1224,7 +1208,7 @@ impl Diagnostic for ParseError { type Subject = String; fn url() -> &'static str { - impl_diagnostic_url!(struct ParseError) + diagnostic_url!(struct ParseError) } fn labels(&self, subject: &Self::Subject) -> Option>> { @@ -1248,10 +1232,15 @@ impl fmt::Display for ParseError { Self::NoLeadingBackslash { .. } => { write!( f, - "json pointer is malformed as it does not start with a backslash ('/') and is not empty" + "json pointer failed to parse; does not start with a backslash ('/') and is not empty" + ) + } + Self::InvalidEncoding { offset, .. } => { + write!( + f, + "json pointer failed to parse; the first token in the partial-pointer starting at offset {offset} is malformed" ) } - Self::InvalidEncoding { source, .. } => fmt::Display::fmt(source, f), } } } @@ -1335,16 +1324,6 @@ impl std::error::Error for ParseError { /// A rich error type that includes the original string that failed to parse. pub type RichParseError = Report; -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ ReplaceError ║ -║ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// Returned from [`PointerBuf::replace`] when the provided index is out of /// bounds. #[derive(Debug, PartialEq, Eq)] @@ -1430,16 +1409,6 @@ const fn validate_bytes(bytes: &[u8], offset: usize) -> Result<(), ParseError> { Ok(()) } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Tests ║ -║ ¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(test)] mod tests { use std::error::Error; @@ -2373,7 +2342,7 @@ mod tests { #[test] fn quick_miette_spike() { - let err = PointerBuf::parse("hello-world").unwrap_err(); - println!("{:?}", miette::Report::from(err)); + // let err = PointerBuf::parse("hello-world").unwrap_err(); + // println!("{:?}", miette::Report::from(err)); } } diff --git a/src/resolve.rs b/src/resolve.rs index 38f2d79..a71456b 100644 --- a/src/resolve.rs +++ b/src/resolve.rs @@ -33,21 +33,14 @@ //! | TOML | `toml::Value` | `"toml"` | | //! //! +use core::iter::once; + use crate::{ + diagnostic::{diagnostic_url, Diagnostic, Label}, index::{OutOfBoundsError, ParseIndexError}, - Pointer, Token, + Pointer, PointerBuf, Token, }; -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Resolve ║ -║ ¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// A trait implemented by types which can resolve a reference to a value type /// from a path represented by a JSON [`Pointer`]. pub trait Resolve { @@ -65,16 +58,6 @@ pub trait Resolve { fn resolve(&self, ptr: &Pointer) -> Result<&Self::Value, Self::Error>; } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ ResolveMut ║ -║ ¯¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - /// A trait implemented by types which can resolve a mutable reference to a /// value type from a path represented by a JSON [`Pointer`]. pub trait ResolveMut { @@ -93,16 +76,6 @@ pub trait ResolveMut { fn resolve_mut(&mut self, ptr: &Pointer) -> Result<&mut Self::Value, Self::Error>; } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Error ║ -║ ¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - // TODO: should ResolveError be deprecated? /// Alias for [`Error`]. pub type ResolveError = Error; @@ -233,6 +206,32 @@ impl Error { } } +impl Diagnostic for Error { + type Subject = PointerBuf; + + fn url() -> &'static str { + diagnostic_url!(enum assign::Error) + } + + fn labels(&self, origin: &Self::Subject) -> Option>> { + let position = self.position(); + let token = origin.get(position)?; + let offset = if self.offset() + 1 < origin.as_str().len() { + self.offset() + 1 + } else { + self.offset() + }; + let len = token.encoded().len(); + let text = match self { + Error::FailedToParseIndex { .. } => "not an array index".to_string(), + Error::OutOfBounds { source, .. } => source.to_string(), + Error::NotFound { .. } => "not found in value".to_string(), + Error::Unreachable { .. } => "unreachable".to_string(), + }; + Some(Box::new(once(Label::new(text, offset, len)))) + } +} + impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { @@ -266,16 +265,6 @@ impl std::error::Error for Error { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ json impl ║ -║ ¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(feature = "json")] mod json { use super::{parse_index, Error, Pointer, Resolve, ResolveMut}; @@ -373,16 +362,6 @@ fn parse_index( }) } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ toml impl ║ -║ ¯¯¯¯¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(feature = "toml")] mod toml { use super::{Error, Resolve, ResolveMut}; @@ -474,16 +453,6 @@ mod toml { } } -/* -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ ║ -║ Tests ║ -║ ¯¯¯¯¯¯¯ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ -░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ -*/ - #[cfg(test)] mod tests { use super::{Error, Resolve, ResolveMut}; diff --git a/src/token.rs b/src/token.rs index fe574a2..0944751 100644 --- a/src/token.rs +++ b/src/token.rs @@ -383,7 +383,7 @@ pub struct EncodingError { #[cfg(feature = "std")] impl std::error::Error for EncodingError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { Some(&self.source) } }