Skip to content

Commit

Permalink
Fixes and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Sep 10, 2024
1 parent bd3c625 commit 205973b
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions pest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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`
12 changes: 7 additions & 5 deletions pest/src/error.rs
Original file line number Diff line number Diff line change
@@ -600,7 +600,7 @@ impl<R: RuleType> Error<R> {
}
}

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<R: RuleType>(pub(crate) Error<R>);
pub(crate) struct MietteAdapter<R: RuleType>(pub(crate) Error<R>);

impl<R: RuleType> Diagnostic for MietteAdapter<R> {
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());

0 comments on commit 205973b

Please sign in to comment.