Skip to content

Commit 8c9c282

Browse files
committed
use thiserror
1 parent 55061c7 commit 8c9c282

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/core/src/error.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ impl<T> std::ops::Deref for BaseError<T> {
1616
}
1717
}
1818

19-
impl<T> std::error::Error for BaseError<T>
20-
where
21-
T: std::fmt::Display + std::fmt::Debug,
22-
{
23-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
24-
None
25-
}
26-
}
19+
impl<T> std::error::Error for BaseError<T> where T: std::fmt::Display + std::fmt::Debug {}
2720

2821
impl<T> Display for BaseError<T>
2922
where

compiler/parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ phf = "0.10.1"
2828
unic-emoji-char = "0.9.0"
2929
unic-ucd-ident = "0.9.0"
3030
unicode_names2 = "0.5.0"
31+
thiserror = "1.0"
3132

3233
[dev-dependencies]
3334
insta = "1.14.0"

compiler/parser/src/error.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use crate::{ast::Location, token::Tok};
55
use lalrpop_util::ParseError as LalrpopError;
6-
use std::{error::Error, fmt};
6+
use std::fmt;
77

88
/// Represents an error during lexical scanning.
99
#[derive(Debug, PartialEq)]
@@ -119,7 +119,7 @@ impl From<FStringError> for LalrpopError<Location, Tok, LexicalError> {
119119
/// Represents an error during parsing
120120
pub type ParseError = rustpython_compiler_core::BaseError<ParseErrorType>;
121121

122-
#[derive(Debug, PartialEq)]
122+
#[derive(Debug, PartialEq, thiserror::Error)]
123123
pub enum ParseErrorType {
124124
/// Parser encountered an unexpected end of input
125125
Eof,
@@ -194,8 +194,6 @@ impl fmt::Display for ParseErrorType {
194194
}
195195
}
196196

197-
impl Error for ParseErrorType {}
198-
199197
impl ParseErrorType {
200198
pub fn is_indentation_error(&self) -> bool {
201199
match self {

0 commit comments

Comments
 (0)