Skip to content

Commit

Permalink
Merge pull request #469 from DaniPopes/parse-error-string
Browse files Browse the repository at this point in the history
Store str instead of String in ParseError
  • Loading branch information
Alex-Fischman authored Nov 13, 2024
2 parents 9360431 + 4031ed9 commit ca52ac1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ast/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn ident(ctx: &Context) -> Res<Symbol> {
}
}

fn text(s: &str) -> impl Parser<()> + '_ {
fn text(s: &'static str) -> impl Parser<()> {
move |ctx| {
let mut span = ctx.span();
span.2 = (span.1 + s.len()).min(ctx.source.contents.len());
Expand All @@ -200,7 +200,7 @@ fn text(s: &str) -> impl Parser<()> + '_ {
next.advance_past_whitespace();
Ok(((), span, next))
} else {
Err(ParseError::Text(span, s.to_string()))
Err(ParseError::Text(span, s))
}
}
}
Expand Down Expand Up @@ -280,7 +280,7 @@ fn option<T>(parser: impl Parser<T>) -> impl Parser<Option<T>> {
fn parens<T>(f: impl Parser<T>) -> impl Parser<T> {
choice(
sequence3(text("["), f.clone(), text("]")),
sequence3(text("("), f.clone(), text(")")),
sequence3(text("("), f, text(")")),
)
.map(|((), x, ()), _| x)
}
Expand Down Expand Up @@ -791,7 +791,7 @@ fn string(ctx: &Context) -> Res<String> {
#[derive(Debug, Error)]
pub enum ParseError {
#[error("{0}\nexpected \"{1}\"")]
Text(Span, String),
Text(Span, &'static str),
#[error("{0}\nexpected string")]
String(Span),
#[error("{0}\nmissing end quote for string")]
Expand Down

0 comments on commit ca52ac1

Please sign in to comment.