@@ -149,7 +149,7 @@ impl<T> WithFilePath<T> for Result<T, RichError> {
149149#[ derive( Debug , Clone , Eq , PartialEq , Hash ) ]
150150pub struct RichError {
151151 /// The error that occurred.
152- error : Error ,
152+ error : Box < Error > ,
153153 /// Area that the error spans inside the file.
154154 span : Span ,
155155 /// File contents in which the error occurred.
@@ -164,7 +164,7 @@ impl RichError {
164164 /// Create a new error with context.
165165 pub fn new ( error : Error , span : Span ) -> RichError {
166166 RichError {
167- error,
167+ error : Box :: new ( error ) ,
168168 span,
169169 file : None ,
170170 file_path : None ,
@@ -193,7 +193,7 @@ impl RichError {
193193 /// a problem on the parsing side.
194194 pub fn parsing_error ( reason : & str ) -> Self {
195195 Self {
196- error : Error :: CannotParse ( reason. to_string ( ) ) ,
196+ error : Box :: new ( Error :: CannotParse ( reason. to_string ( ) ) ) ,
197197 span : Span :: new ( 0 , 0 ) ,
198198 file : None ,
199199 file_path : None ,
@@ -315,7 +315,7 @@ impl std::error::Error for RichError {}
315315
316316impl From < RichError > for Error {
317317 fn from ( error : RichError ) -> Self {
318- error. error
318+ * error. error
319319 }
320320}
321321
@@ -331,7 +331,7 @@ where
331331 I : ValueInput < ' tokens , Token = Token < ' src > , Span = Span > ,
332332{
333333 fn merge ( self , other : Self ) -> Self {
334- match ( & self . error , & other. error ) {
334+ match ( self . error . as_ref ( ) , other. error . as_ref ( ) ) {
335335 ( Error :: Grammar ( _) , Error :: Grammar ( _) ) => other,
336336 ( Error :: Grammar ( _) , _) => other,
337337 ( _, Error :: Grammar ( _) ) => self ,
@@ -367,11 +367,11 @@ where
367367 let found_string = found. map ( |t| t. to_string ( ) ) ;
368368
369369 Self {
370- error : Error :: Syntax {
370+ error : Box :: new ( Error :: Syntax {
371371 expected : expected_tokens,
372372 label : None ,
373373 found : found_string,
374- } ,
374+ } ) ,
375375 span,
376376 file : None ,
377377 file_path : None ,
@@ -395,11 +395,11 @@ where
395395 let found_string = found. map ( |t| t. to_string ( ) ) ;
396396
397397 Self {
398- error : Error :: Syntax {
398+ error : Box :: new ( Error :: Syntax {
399399 expected : expected_strings,
400400 label : None ,
401401 found : found_string,
402- } ,
402+ } ) ,
403403 span,
404404 file : None ,
405405 file_path : None ,
@@ -409,7 +409,7 @@ where
409409 fn label_with ( & mut self , label : & ' tokens str ) {
410410 if let Error :: Syntax {
411411 label : ref mut l, ..
412- } = & mut self . error
412+ } = self . error . as_mut ( )
413413 {
414414 * l = Some ( label. to_string ( ) ) ;
415415 }
0 commit comments