mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-23 04:55:25 +00:00
integrate CodegenError to compiler-core::Error
This commit is contained in:
parent
2b7bf79d29
commit
7fcc18daea
2 changed files with 21 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use crate::Location;
|
use crate::Location;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
@ -15,6 +17,24 @@ impl<T> std::ops::Deref for Error<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::error::Error for Error<T>
|
||||||
|
where
|
||||||
|
T: std::fmt::Display + std::fmt::Debug,
|
||||||
|
{
|
||||||
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Display for Error<T>
|
||||||
|
where
|
||||||
|
T: std::fmt::Display,
|
||||||
|
{
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
self.location.fmt_with(f, &self.error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Error<T> {
|
impl<T> Error<T> {
|
||||||
pub fn error(self) -> T {
|
pub fn error(self) -> T {
|
||||||
self.error
|
self.error
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl ParseError {
|
||||||
|
|
||||||
impl fmt::Display for ParseError {
|
impl fmt::Display for ParseError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.location.fmt_with(f, &self.error)
|
self.0.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue