Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/validation.rs')
-rw-r--r--crates/syntax/src/validation.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs
index 5bfeb3bff8..4180f9cd18 100644
--- a/crates/syntax/src/validation.rs
+++ b/crates/syntax/src/validation.rs
@@ -6,7 +6,9 @@ mod block;
use itertools::Itertools;
use rowan::Direction;
-use rustc_literal_escaper::{self, EscapeError, Mode, unescape_mixed, unescape_unicode};
+use rustc_literal_escaper::{
+ EscapeError, unescape_byte, unescape_byte_str, unescape_c_str, unescape_char, unescape_str,
+};
use crate::{
AstNode, SyntaxError,
@@ -47,7 +49,7 @@ pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
}
fn rustc_unescape_error_to_string(err: EscapeError) -> (&'static str, bool) {
- use rustc_literal_escaper::EscapeError as EE;
+ use EscapeError as EE;
#[rustfmt::skip]
let err_message = match err {
@@ -142,7 +144,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
ast::LiteralKind::String(s) => {
if !s.is_raw() {
if let Some(without_quotes) = unquote(text, 1, '"') {
- unescape_unicode(without_quotes, Mode::Str, &mut |range, char| {
+ unescape_str(without_quotes, |range, char| {
if let Err(err) = char {
push_err(1, range.start, err);
}
@@ -153,7 +155,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
ast::LiteralKind::ByteString(s) => {
if !s.is_raw() {
if let Some(without_quotes) = unquote(text, 2, '"') {
- unescape_unicode(without_quotes, Mode::ByteStr, &mut |range, char| {
+ unescape_byte_str(without_quotes, |range, char| {
if let Err(err) = char {
push_err(1, range.start, err);
}
@@ -164,7 +166,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
ast::LiteralKind::CString(s) => {
if !s.is_raw() {
if let Some(without_quotes) = unquote(text, 2, '"') {
- unescape_mixed(without_quotes, Mode::CStr, &mut |range, char| {
+ unescape_c_str(without_quotes, |range, char| {
if let Err(err) = char {
push_err(1, range.start, err);
}
@@ -174,20 +176,16 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
}
ast::LiteralKind::Char(_) => {
if let Some(without_quotes) = unquote(text, 1, '\'') {
- unescape_unicode(without_quotes, Mode::Char, &mut |range, char| {
- if let Err(err) = char {
- push_err(1, range.start, err);
- }
- });
+ if let Err(err) = unescape_char(without_quotes) {
+ push_err(1, 0, err);
+ }
}
}
ast::LiteralKind::Byte(_) => {
if let Some(without_quotes) = unquote(text, 2, '\'') {
- unescape_unicode(without_quotes, Mode::Byte, &mut |range, char| {
- if let Err(err) = char {
- push_err(2, range.start, err);
- }
- });
+ if let Err(err) = unescape_byte(without_quotes) {
+ push_err(2, 0, err);
+ }
}
}
ast::LiteralKind::IntNumber(_)