@@ -58,59 +58,3 @@ impl<T> BaseError<T> {
58
58
BaseError :: from ( self )
59
59
}
60
60
}
61
-
62
- #[ derive( Debug ) ]
63
- pub struct CompileError < T > {
64
- pub body : BaseError < T > ,
65
- pub statement : Option < String > ,
66
- }
67
-
68
- impl < T : StdError + ' static > StdError for CompileError < T > {
69
- fn source ( & self ) -> Option < & ( dyn StdError + ' static ) > {
70
- self . body . source ( )
71
- }
72
- }
73
-
74
- impl < T > std:: ops:: Deref for CompileError < T > {
75
- type Target = BaseError < T > ;
76
- fn deref ( & self ) -> & Self :: Target {
77
- & self . body
78
- }
79
- }
80
-
81
- impl < T > std:: fmt:: Display for CompileError < T >
82
- where
83
- T : std:: fmt:: Display ,
84
- {
85
- fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
86
- let loc = self . location ;
87
- if let Some ( ref stmt) = self . statement {
88
- // visualize the error when location and statement are provided
89
- loc. fmt_with ( f, & self . error ) ?;
90
- write ! ( f, "\n {stmt}{arrow:>pad$}" , pad = loc. column( ) , arrow = "^" )
91
- } else {
92
- loc. fmt_with ( f, & self . error )
93
- }
94
- }
95
- }
96
-
97
- impl < T > CompileError < T > {
98
- pub fn from < U > ( error : BaseError < U > , source : & str ) -> Self
99
- where
100
- T : From < U > ,
101
- {
102
- let statement = get_statement ( source, error. location ) ;
103
- CompileError {
104
- body : error. into ( ) ,
105
- statement,
106
- }
107
- }
108
- }
109
-
110
- fn get_statement ( source : & str , loc : Location ) -> Option < String > {
111
- if loc. column ( ) == 0 || loc. row ( ) == 0 {
112
- return None ;
113
- }
114
- let line = source. split ( '\n' ) . nth ( loc. row ( ) - 1 ) ?. to_owned ( ) ;
115
- Some ( line + "\n " )
116
- }
0 commit comments