1
1
use std:: { char, iter:: Peekable , str:: CharIndices } ;
2
2
3
- use derive_more:: with_trait:: Display ;
3
+ use derive_more:: with_trait:: { Display , Error } ;
4
4
5
5
use crate :: parser:: { SourcePosition , Spanning } ;
6
6
@@ -63,21 +63,21 @@ pub enum Token<'a> {
63
63
}
64
64
65
65
/// Error when tokenizing the input source
66
- #[ derive( Clone , Debug , Display , Eq , PartialEq ) ]
66
+ #[ derive( Clone , Debug , Display , Eq , Error , PartialEq ) ]
67
67
pub enum LexerError {
68
68
/// An unknown character was found
69
69
///
70
70
/// Unknown characters are characters that do not occur anywhere in the
71
71
/// GraphQL language, such as `?` or `%`.
72
72
#[ display( "Unknown character \" {_0}\" " ) ]
73
- UnknownCharacter ( char ) ,
73
+ UnknownCharacter ( # [ error ( not ( source ) ) ] char ) ,
74
74
75
75
/// An unexpected character was found
76
76
///
77
77
/// Unexpected characters are characters that _do_ exist in the GraphQL
78
78
/// language, but is not expected at the current position in the document.
79
79
#[ display( "Unexpected character \" {_0}\" " ) ]
80
- UnexpectedCharacter ( char ) ,
80
+ UnexpectedCharacter ( # [ error ( not ( source ) ) ] char ) ,
81
81
82
82
/// An unterminated string literal was found
83
83
///
@@ -92,14 +92,14 @@ pub enum LexerError {
92
92
/// This occurs when an invalid source character is found in a string
93
93
/// literal, such as ASCII control characters.
94
94
#[ display( "Unknown character \" {_0}\" in string literal" ) ]
95
- UnknownCharacterInString ( char ) ,
95
+ UnknownCharacterInString ( # [ error ( not ( source ) ) ] char ) ,
96
96
97
97
/// An unknown escape sequence in a string literal was found
98
98
///
99
99
/// Only a limited set of escape sequences are supported, this is emitted
100
100
/// when e.g. `"\l"` is parsed.
101
101
#[ display( "Unknown escape sequence \" {_0}\" in string" ) ]
102
- UnknownEscapeSequence ( String ) ,
102
+ UnknownEscapeSequence ( # [ error ( not ( source ) ) ] String ) ,
103
103
104
104
/// The input source was unexpectedly terminated
105
105
///
@@ -516,5 +516,3 @@ fn is_name_cont(c: char) -> bool {
516
516
fn is_number_start ( c : char ) -> bool {
517
517
c == '-' || c. is_ascii_digit ( )
518
518
}
519
-
520
- impl std:: error:: Error for LexerError { }
0 commit comments