|
1 | 1 | //! Lexer analyzes raw input string and produces lexemes (tokens). |
2 | 2 | //! It is just a bridge to `rustc_lexer`. |
3 | 3 |
|
| 4 | +use rustc_lexer::{LiteralKind as LK, RawStrError}; |
| 5 | + |
4 | 6 | use std::convert::TryInto; |
5 | 7 |
|
6 | 8 | use crate::{ |
@@ -180,8 +182,6 @@ fn rustc_token_kind_to_syntax_kind( |
180 | 182 | return (syntax_kind, None); |
181 | 183 |
|
182 | 184 | fn match_literal_kind(kind: &rustc_lexer::LiteralKind) -> (SyntaxKind, Option<&'static str>) { |
183 | | - use rustc_lexer::{LexRawStrError, LiteralKind as LK}; |
184 | | - |
185 | 185 | #[rustfmt::skip] |
186 | 186 | let syntax_kind = match *kind { |
187 | 187 | LK::Int { empty_int: false, .. } => INT_NUMBER, |
@@ -215,27 +215,27 @@ fn rustc_token_kind_to_syntax_kind( |
215 | 215 | return (BYTE_STRING, Some("Missing trailing `\"` symbol to terminate the byte string literal")) |
216 | 216 | } |
217 | 217 |
|
218 | | - LK::RawStr(str) => match str.validate() { |
219 | | - Ok(_) => RAW_STRING, |
220 | | - Err(LexRawStrError::InvalidStarter) => return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal")), |
221 | | - Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found { |
| 218 | + LK::RawStr { err, .. } => match err { |
| 219 | + None => RAW_STRING, |
| 220 | + Some(RawStrError::InvalidStarter { .. }) => return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal")), |
| 221 | + Some(RawStrError::NoTerminator { expected, found, .. }) => if expected == found { |
222 | 222 | return (RAW_STRING, Some("Missing trailing `\"` to terminate the raw string literal")) |
223 | 223 | } else { |
224 | 224 | return (RAW_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw string literal")) |
225 | 225 |
|
226 | 226 | }, |
227 | | - Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_STRING, Some("Too many `#` symbols: raw strings may be delimited by up to 65535 `#` symbols")), |
| 227 | + Some(RawStrError::TooManyDelimiters { .. }) => return (RAW_STRING, Some("Too many `#` symbols: raw strings may be delimited by up to 65535 `#` symbols")), |
228 | 228 | }, |
229 | | - LK::RawByteStr(str) => match str.validate() { |
230 | | - Ok(_) => RAW_BYTE_STRING, |
231 | | - Err(LexRawStrError::InvalidStarter) => return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal")), |
232 | | - Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found { |
| 229 | + LK::RawByteStr { err, .. } => match err { |
| 230 | + None => RAW_BYTE_STRING, |
| 231 | + Some(RawStrError::InvalidStarter { .. }) => return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal")), |
| 232 | + Some(RawStrError::NoTerminator { expected, found, .. }) => if expected == found { |
233 | 233 | return (RAW_BYTE_STRING, Some("Missing trailing `\"` to terminate the raw byte string literal")) |
234 | 234 | } else { |
235 | 235 | return (RAW_BYTE_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw byte string literal")) |
236 | 236 |
|
237 | 237 | }, |
238 | | - Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_BYTE_STRING, Some("Too many `#` symbols: raw byte strings may be delimited by up to 65535 `#` symbols")), |
| 238 | + Some(RawStrError::TooManyDelimiters { .. }) => return (RAW_BYTE_STRING, Some("Too many `#` symbols: raw byte strings may be delimited by up to 65535 `#` symbols")), |
239 | 239 | }, |
240 | 240 | }; |
241 | 241 |
|
|
0 commit comments