diff options
Diffstat (limited to 'crates/ra_syntax/src/syntax_error.rs')
-rw-r--r-- | crates/ra_syntax/src/syntax_error.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs index 9122dda29..af18a30f2 100644 --- a/crates/ra_syntax/src/syntax_error.rs +++ b/crates/ra_syntax/src/syntax_error.rs | |||
@@ -84,6 +84,9 @@ pub enum SyntaxErrorKind { | |||
84 | ParseError(ParseError), | 84 | ParseError(ParseError), |
85 | EscapeError(EscapeError), | 85 | EscapeError(EscapeError), |
86 | TokenizeError(TokenizeError), | 86 | TokenizeError(TokenizeError), |
87 | // FIXME: the obvious pattern of this enum dictates that the following enum variants | ||
88 | // should be wrapped into something like `SemmanticError(SemmanticError)` | ||
89 | // or `ValidateError(ValidateError)` or `SemmanticValidateError(...)` | ||
87 | InvalidBlockAttr, | 90 | InvalidBlockAttr, |
88 | InvalidMatchInnerAttr, | 91 | InvalidMatchInnerAttr, |
89 | InvalidTupleIndexFormat, | 92 | InvalidTupleIndexFormat, |
@@ -106,6 +109,7 @@ impl fmt::Display for SyntaxErrorKind { | |||
106 | } | 109 | } |
107 | ParseError(msg) => write!(f, "{}", msg.0), | 110 | ParseError(msg) => write!(f, "{}", msg.0), |
108 | EscapeError(err) => write!(f, "{}", err), | 111 | EscapeError(err) => write!(f, "{}", err), |
112 | TokenizeError(err) => write!(f, "{}", err), | ||
109 | VisibilityNotAllowed => { | 113 | VisibilityNotAllowed => { |
110 | write!(f, "unnecessary visibility qualifier") | 114 | write!(f, "unnecessary visibility qualifier") |
111 | } | 115 | } |
@@ -116,6 +120,44 @@ impl fmt::Display for SyntaxErrorKind { | |||
116 | } | 120 | } |
117 | } | 121 | } |
118 | 122 | ||
123 | impl fmt::Display for TokenizeError { | ||
124 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
125 | let msg = match self { | ||
126 | TokenizeError::EmptyInt => "Missing digits after integer base prefix", | ||
127 | TokenizeError::EmptyExponent => "Missing digits after the exponent symbol", | ||
128 | TokenizeError::UnterminatedBlockComment => { | ||
129 | "Missing trailing `*/` symbols to terminate the block comment" | ||
130 | } | ||
131 | TokenizeError::UnterminatedChar => { | ||
132 | "Missing trailing `'` symbol to terminate the character literal" | ||
133 | } | ||
134 | TokenizeError::UnterminatedByte => { | ||
135 | "Missing trailing `'` symbol to terminate the byte literal" | ||
136 | } | ||
137 | TokenizeError::UnterminatedString => { | ||
138 | "Missing trailing `\"` symbol to terminate the string literal" | ||
139 | } | ||
140 | TokenizeError::UnterminatedByteString => { | ||
141 | "Missing trailing `\"` symbol to terminate the byte string literal" | ||
142 | } | ||
143 | TokenizeError::UnterminatedRawString => { | ||
144 | "Missing trailing `\"` with `#` symbols to terminate the raw string literal" | ||
145 | } | ||
146 | TokenizeError::UnterminatedRawByteString => { | ||
147 | "Missing trailing `\"` with `#` symbols to terminate the raw byte string literal" | ||
148 | } | ||
149 | TokenizeError::UnstartedRawString => { | ||
150 | "Missing `\"` symbol after `#` symbols to begin the raw string literal" | ||
151 | } | ||
152 | TokenizeError::UnstartedRawByteString => { | ||
153 | "Missing `\"` symbol after `#` symbols to begin the raw byte string literal" | ||
154 | } | ||
155 | TokenizeError::LifetimeStartsWithNumber => "Lifetime name cannot start with a number", | ||
156 | }; | ||
157 | write!(f, "{}", msg) | ||
158 | } | ||
159 | } | ||
160 | |||
119 | impl fmt::Display for EscapeError { | 161 | impl fmt::Display for EscapeError { |
120 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 162 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
121 | let msg = match self { | 163 | let msg = match self { |