From 41ab00deccc687ae9d3ec42cb3009d85c872c352 Mon Sep 17 00:00:00 2001 From: Ryu <114303361+ryuapp@users.noreply.github.com> Date: Wed, 3 Jun 2026 20:52:46 +0900 Subject: [PATCH] refactor: remove thiserror dependency --- Cargo.lock | 56 --------------------------------------------------- Cargo.toml | 1 - src/parser.rs | 19 ++++++++++++----- 3 files changed, 14 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb24bdc..f9eba06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,65 +8,9 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" -[[package]] -name = "proc-macro2" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" -dependencies = [ - "proc-macro2", -] - [[package]] name = "rysh" version = "0.1.0" dependencies = [ "anyhow", - "thiserror", -] - -[[package]] -name = "syn" -version = "2.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" -dependencies = [ - "proc-macro2", - "quote", - "syn", ] - -[[package]] -name = "unicode-ident" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" diff --git a/Cargo.toml b/Cargo.toml index 3ab5a9f..6b17536 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,3 @@ path = "src/main.rs" [dependencies] anyhow = "1.0.98" -thiserror = "2.0.12" diff --git a/src/parser.rs b/src/parser.rs index 583e6aa..8c909b8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -14,14 +14,23 @@ impl Word { } } -#[derive(Debug, thiserror::Error, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq)] pub(crate) enum ParseError { - #[error("unterminated quote")] UnterminatedQuote, - #[error("expected command after operator")] ExpectedCommand, - #[error("expected redirect target")] ExpectedRedirectTarget, - #[error("unexpected token: {0}")] UnexpectedToken(String), } + +impl std::fmt::Display for ParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::UnterminatedQuote => write!(f, "unterminated quote"), + Self::ExpectedCommand => write!(f, "expected command after operator"), + Self::ExpectedRedirectTarget => write!(f, "expected redirect target"), + Self::UnexpectedToken(token) => write!(f, "unexpected token: {token}"), + } + } +} + +impl std::error::Error for ParseError {}