Skip to content

Commit cd4ffc1

Browse files
Update to rustc_lexer version 660.
Change `unescape_*()` to `unescape_literal()`.
1 parent f4f5fca commit cd4ffc1

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_syntax/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doctest = false
1313
[dependencies]
1414
itertools = "0.9.0"
1515
rowan = "0.10.0"
16-
rustc_lexer = { version = "656.0.0", package = "rustc-ap-rustc_lexer" }
16+
rustc_lexer = { version = "660.0.0", package = "rustc-ap-rustc_lexer" }
1717
rustc-hash = "1.1.0"
1818
arrayvec = "0.5.1"
1919
once_cell = "1.3.1"

crates/ra_syntax/src/ast/tokens.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
ast::{AstToken, Comment, RawString, String, Whitespace},
77
TextRange, TextSize,
88
};
9+
use rustc_lexer::unescape::{unescape_literal, Mode};
910

1011
impl Comment {
1112
pub fn kind(&self) -> CommentKind {
@@ -147,7 +148,7 @@ impl HasStringValue for String {
147148

148149
let mut buf = std::string::String::with_capacity(text.len());
149150
let mut has_error = false;
150-
rustc_lexer::unescape::unescape_str(text, &mut |_, unescaped_char| match unescaped_char {
151+
unescape_literal(text, Mode::Str, &mut |_, unescaped_char| match unescaped_char {
151152
Ok(c) => buf.push(c),
152153
Err(_) => has_error = true,
153154
});
@@ -498,7 +499,7 @@ impl HasFormatSpecifier for String {
498499
let offset = self.text_range_between_quotes()?.start() - self.syntax().text_range().start();
499500

500501
let mut res = Vec::with_capacity(text.len());
501-
rustc_lexer::unescape::unescape_str(text, &mut |range, unescaped_char| {
502+
unescape_literal(text, Mode::Str, &mut |range, unescaped_char| {
502503
res.push((
503504
TextRange::new(range.start.try_into().unwrap(), range.end.try_into().unwrap())
504505
+ offset,

crates/ra_syntax/src/validation.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
33
mod block;
44

5-
use std::convert::TryFrom;
6-
7-
use rustc_lexer::unescape;
8-
95
use crate::{
106
ast, match_ast, AstNode, SyntaxError,
117
SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF},
128
SyntaxNode, SyntaxToken, TextSize, T,
139
};
10+
use rustc_lexer::unescape::{
11+
self, unescape_byte, unescape_byte_literal, unescape_char, unescape_literal, Mode,
12+
};
13+
use std::convert::TryFrom;
1414

1515
fn rustc_unescape_error_to_string(err: unescape::EscapeError) -> &'static str {
1616
use unescape::EscapeError as EE;
@@ -121,18 +121,18 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
121121

122122
match token.kind() {
123123
BYTE => {
124-
if let Some(Err(e)) = unquote(text, 2, '\'').map(unescape::unescape_byte) {
124+
if let Some(Err(e)) = unquote(text, 2, '\'').map(unescape_byte) {
125125
push_err(2, e);
126126
}
127127
}
128128
CHAR => {
129-
if let Some(Err(e)) = unquote(text, 1, '\'').map(unescape::unescape_char) {
129+
if let Some(Err(e)) = unquote(text, 1, '\'').map(unescape_char) {
130130
push_err(1, e);
131131
}
132132
}
133133
BYTE_STRING => {
134134
if let Some(without_quotes) = unquote(text, 2, '"') {
135-
unescape::unescape_byte_str(without_quotes, &mut |range, char| {
135+
unescape_byte_literal(without_quotes, Mode::ByteStr, &mut |range, char| {
136136
if let Err(err) = char {
137137
push_err(2, (range.start, err));
138138
}
@@ -141,7 +141,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
141141
}
142142
STRING => {
143143
if let Some(without_quotes) = unquote(text, 1, '"') {
144-
unescape::unescape_str(without_quotes, &mut |range, char| {
144+
unescape_literal(without_quotes, Mode::Str, &mut |range, char| {
145145
if let Err(err) = char {
146146
push_err(1, (range.start, err));
147147
}

0 commit comments

Comments
 (0)