From 04ffcda99adc29373786cf2a03ec8a735b575498 Mon Sep 17 00:00:00 2001 From: Thomas M Kehrenberg Date: Mon, 9 Mar 2026 15:54:48 +0100 Subject: [PATCH] Simplify error enum --- crates/math-core/src/error.rs | 8 ++++---- crates/math-core/src/parser.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/math-core/src/error.rs b/crates/math-core/src/error.rs index 2cea79ca..31fbe11c 100644 --- a/crates/math-core/src/error.rs +++ b/crates/math-core/src/error.rs @@ -37,7 +37,7 @@ pub(crate) enum LatexErrKind { BoundFollowedByBound, DuplicateSubOrSup, SwitchOnlyInSequence, - ExpectedText(&'static str), + ExpectedText, ExpectedLength(Box), ExpectedColSpec(Box), ExpectedNumber(Box), @@ -163,8 +163,8 @@ impl LatexErrKind { LatexErrKind::SwitchOnlyInSequence => { write!(s, "Math variant switch command found outside of sequence.")?; } - LatexErrKind::ExpectedText(place) => { - write!(s, "Expected text in {place}.")?; + LatexErrKind::ExpectedText => { + write!(s, "Expected text in string literal.")?; } LatexErrKind::ExpectedLength(got) => { write!(s, "Expected length with units, got \"{got}\".")?; @@ -301,7 +301,7 @@ impl LatexError { LatexErrKind::BoundFollowedByBound => "unexpected bound".into(), LatexErrKind::DuplicateSubOrSup => "duplicate".into(), LatexErrKind::SwitchOnlyInSequence => "math variant switch command as argument".into(), - LatexErrKind::ExpectedText(_) => "expected text here".into(), + LatexErrKind::ExpectedText => "expected text here".into(), LatexErrKind::ExpectedLength(_) => "expected length here".into(), LatexErrKind::ExpectedNumber(_) => "expected a number here".into(), LatexErrKind::ExpectedColSpec(_) => "expected a column spec here".into(), diff --git a/crates/math-core/src/parser.rs b/crates/math-core/src/parser.rs index 3529385c..3c3861d7 100644 --- a/crates/math-core/src/parser.rs +++ b/crates/math-core/src/parser.rs @@ -1675,7 +1675,7 @@ where let Some(ch) = recover_limited_ascii(tok) else { return Err(Box::new(LatexError( span.into(), - LatexErrKind::ExpectedText("string literal"), + LatexErrKind::ExpectedText, ))); }; builder.push_char(ch);