From 205973ba5e0e2231e23477add8cadd36fa35af5a Mon Sep 17 00:00:00 2001 From: prsabahrami Date: Tue, 10 Sep 2024 10:23:21 -0400 Subject: [PATCH] Fixes and cargo fmt --- pest/Cargo.toml | 1 + pest/src/error.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pest/Cargo.toml b/pest/Cargo.toml index cac6eb8e..238e905b 100644 --- a/pest/Cargo.toml +++ b/pest/Cargo.toml @@ -14,6 +14,7 @@ readme = "_README.md" rust-version = "1.61" [features] +default = ["std", "memchr"] # Implements `std::error::Error` for the `Error` type std = ["ucd-trie/std", "dep:thiserror"] # Enables the `to_json` function for `Pair` and `Pairs` diff --git a/pest/src/error.rs b/pest/src/error.rs index 5d02d668..e9b48f61 100644 --- a/pest/src/error.rs +++ b/pest/src/error.rs @@ -600,7 +600,7 @@ impl Error { } } - pub fn format(&self) -> String { + pub(crate) fn format(&self) -> String { let spacing = self.spacing(); let path = self .path @@ -747,7 +747,7 @@ mod miette_adapter { #[derive(thiserror::Error, Debug)] #[error("Failure to parse at {}", self.0.line_col)] - pub(crate)struct MietteAdapter(pub(crate) Error); + pub(crate) struct MietteAdapter(pub(crate) Error); impl Diagnostic for MietteAdapter { fn source_code(&self) -> Option<&dyn SourceCode> { @@ -759,7 +759,9 @@ mod miette_adapter { let (offset, length) = match self.0.line_col { LineColLocation::Pos((r, c)) => (c - 1, 1), - LineColLocation::Span((start_r, start_c), (end_r, end_c)) => (start_c - 1, end_c - start_c + 1), + LineColLocation::Span((start_r, start_c), (end_r, end_c)) => { + (start_c - 1, end_c - start_c + 1) + } }; let span = LabeledSpan::new(Some(message), offset, length); @@ -1153,7 +1155,7 @@ mod tests { #[cfg(feature = "miette")] #[test] fn miette_error() { - use miette::{MietteDiagnostic, LabeledSpan, Diagnostic}; + use miette::{Diagnostic, LabeledSpan, MietteDiagnostic}; let input = "abc\ndef"; let pos = position::Position::new(input, 4).unwrap(); @@ -1162,7 +1164,7 @@ mod tests { positives: vec![1, 2, 3], negatives: vec![4, 5, 6], }, - pos, + pos, ); let miette_error = miette::Error::new(error.into_miette());