mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
use thiserror
This commit is contained in:
1 parent
55061c7b6a
commit
8c9c2820b7
4 files changed
+5
-12
No files matched your search
Generated
+1
@@ -1864,6 +1864,7 @@ dependencies = [
|
||||
"phf_codegen",
|
||||
"rustpython-ast",
|
||||
"rustpython-compiler-core",
|
||||
"thiserror",
|
||||
"tiny-keccak",
|
||||
"unic-emoji-char",
|
||||
"unic-ucd-ident",
|
||||
|
||||
@@ -16,14 +16,7 @@ impl<T> std::ops::Deref for BaseError<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::error::Error for BaseError<T>
|
||||
where
|
||||
T: std::fmt::Display + std::fmt::Debug,
|
||||
{
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<T> std::error::Error for BaseError<T> where T: std::fmt::Display + std::fmt::Debug {}
|
||||
|
||||
impl<T> Display for BaseError<T>
|
||||
where
|
||||
|
||||
@@ -28,6 +28,7 @@ phf = "0.10.1"
|
||||
unic-emoji-char = "0.9.0"
|
||||
unic-ucd-ident = "0.9.0"
|
||||
unicode_names2 = "0.5.0"
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = "1.14.0"
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{ast::Location, token::Tok};
|
||||
use lalrpop_util::ParseError as LalrpopError;
|
||||
use std::{error::Error, fmt};
|
||||
use std::fmt;
|
||||
|
||||
/// Represents an error during lexical scanning.
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -119,7 +119,7 @@ impl From<FStringError> for LalrpopError<Location, Tok, LexicalError> {
|
||||
/// Represents an error during parsing
|
||||
pub type ParseError = rustpython_compiler_core::BaseError<ParseErrorType>;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, thiserror::Error)]
|
||||
pub enum ParseErrorType {
|
||||
/// Parser encountered an unexpected end of input
|
||||
Eof,
|
||||
@@ -194,8 +194,6 @@ impl fmt::Display for ParseErrorType {
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for ParseErrorType {}
|
||||
|
||||
impl ParseErrorType {
|
||||
pub fn is_indentation_error(&self) -> bool {
|
||||
match self {
|
||||
|
||||
Reference in new issue
Block a user