Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--Cargo.lock9
-rw-r--r--Cargo.toml1
-rw-r--r--crates/parser/Cargo.toml1
-rw-r--r--crates/parser/src/lexed_str.rs10
-rw-r--r--crates/syntax/Cargo.toml3
-rw-r--r--crates/syntax/src/ast/token_ext.rs2
-rw-r--r--crates/syntax/src/lib.rs9
-rw-r--r--crates/syntax/src/validation.rs8
8 files changed, 22 insertions, 21 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1e1d68f778..745a8097c8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1270,6 +1270,7 @@ dependencies = [
"edition",
"expect-test",
"ra-ap-rustc_lexer",
+ "rustc-literal-escaper",
"stdx",
"tracing",
]
@@ -1744,6 +1745,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
+name = "rustc-literal-escaper"
+version = "0.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0041b6238913c41fe704213a4a9329e2f685a156d1781998128b4149c230ad04"
+
+[[package]]
name = "rustc-stable-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1978,10 +1985,10 @@ dependencies = [
"indexmap",
"itertools",
"parser",
- "ra-ap-rustc_lexer",
"rayon",
"rowan",
"rustc-hash 2.0.0",
+ "rustc-literal-escaper",
"rustc_apfloat",
"smol_str",
"stdx",
diff --git a/Cargo.toml b/Cargo.toml
index ce2d66000e..e221913976 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -136,6 +136,7 @@ pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
rustc-hash = "2.0.0"
+rustc-literal-escaper = "0.0.2"
semver = "1.0.14"
serde = { version = "1.0.192" }
serde_derive = { version = "1.0.192" }
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index a36a39dbee..114a66add6 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -14,6 +14,7 @@ rust-version.workspace = true
[dependencies]
drop_bomb = "0.1.5"
ra-ap-rustc_lexer.workspace = true
+rustc-literal-escaper.workspace = true
tracing = { workspace = true, optional = true }
edition.workspace = true
diff --git a/crates/parser/src/lexed_str.rs b/crates/parser/src/lexed_str.rs
index c97596d509..b0bbc2fa5f 100644
--- a/crates/parser/src/lexed_str.rs
+++ b/crates/parser/src/lexed_str.rs
@@ -10,7 +10,7 @@
use std::ops;
-use rustc_lexer::unescape::{EscapeError, Mode};
+use rustc_literal_escaper::{EscapeError, Mode, unescape_byte, unescape_char, unescape_mixed, unescape_unicode};
use crate::{
Edition,
@@ -282,7 +282,7 @@ impl<'a> Converter<'a> {
let text = &self.res.text[self.offset + 1..][..len - 1];
let i = text.rfind('\'').unwrap();
let text = &text[..i];
- if let Err(e) = rustc_lexer::unescape::unescape_char(text) {
+ if let Err(e) = unescape_char(text) {
err = error_to_diagnostic_message(e, Mode::Char);
}
}
@@ -295,7 +295,7 @@ impl<'a> Converter<'a> {
let text = &self.res.text[self.offset + 2..][..len - 2];
let i = text.rfind('\'').unwrap();
let text = &text[..i];
- if let Err(e) = rustc_lexer::unescape::unescape_byte(text) {
+ if let Err(e) = unescape_byte(text) {
err = error_to_diagnostic_message(e, Mode::Byte);
}
}
@@ -402,14 +402,14 @@ fn unescape_string_error_message(text: &str, mode: Mode) -> &'static str {
let mut error_message = "";
match mode {
Mode::CStr => {
- rustc_lexer::unescape::unescape_mixed(text, mode, &mut |_, res| {
+ unescape_mixed(text, mode, &mut |_, res| {
if let Err(e) = res {
error_message = error_to_diagnostic_message(e, mode);
}
});
}
Mode::ByteStr | Mode::Str => {
- rustc_lexer::unescape::unescape_unicode(text, mode, &mut |_, res| {
+ unescape_unicode(text, mode, &mut |_, res| {
if let Err(e) = res {
error_message = error_to_diagnostic_message(e, mode);
}
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml
index 3fe6e01dc3..6b35639820 100644
--- a/crates/syntax/Cargo.toml
+++ b/crates/syntax/Cargo.toml
@@ -17,13 +17,12 @@ either.workspace = true
itertools.workspace = true
rowan = "=0.15.15"
rustc-hash.workspace = true
+rustc-literal-escaper.workspace = true
indexmap.workspace = true
smol_str.workspace = true
triomphe.workspace = true
tracing.workspace = true
-ra-ap-rustc_lexer.workspace = true
-
parser.workspace = true
stdx.workspace = true
diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs
index df851ab5b2..08bffb9e3a 100644
--- a/crates/syntax/src/ast/token_ext.rs
+++ b/crates/syntax/src/ast/token_ext.rs
@@ -2,7 +2,7 @@
use std::{borrow::Cow, num::ParseIntError};
-use rustc_lexer::unescape::{
+use rustc_literal_escaper::{
unescape_byte, unescape_char, unescape_mixed, unescape_unicode, EscapeError, MixedUnit, Mode,
};
use stdx::always;
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs
index c9e9f468dc..21f1ea5f91 100644
--- a/crates/syntax/src/lib.rs
+++ b/crates/syntax/src/lib.rs
@@ -19,13 +19,6 @@
//! [RFC]: <https://github.com/rust-lang/rfcs/pull/2256>
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
-#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
-
-#[cfg(not(feature = "in-rust-tree"))]
-extern crate ra_ap_rustc_lexer as rustc_lexer;
-#[cfg(feature = "in-rust-tree")]
-extern crate rustc_lexer;
-
mod parsing;
mod ptr;
mod syntax_error;
@@ -64,7 +57,7 @@ pub use rowan::{
api::Preorder, Direction, GreenNode, NodeOrToken, SyntaxText, TextRange, TextSize,
TokenAtOffset, WalkEvent,
};
-pub use rustc_lexer::unescape;
+pub use rustc_literal_escaper as unescape;
pub use smol_str::{format_smolstr, SmolStr, SmolStrBuilder, ToSmolStr};
/// `Parse` is the result of the parsing: a syntax tree and a collection of
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs
index 85eefac734..71c5f9a946 100644
--- a/crates/syntax/src/validation.rs
+++ b/crates/syntax/src/validation.rs
@@ -5,7 +5,7 @@
mod block;
use rowan::Direction;
-use rustc_lexer::unescape::{self, unescape_mixed, unescape_unicode, Mode};
+use rustc_literal_escaper::{unescape_mixed, unescape_unicode, EscapeError, Mode};
use crate::{
algo,
@@ -44,8 +44,8 @@ pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
}
}
-fn rustc_unescape_error_to_string(err: unescape::EscapeError) -> (&'static str, bool) {
- use unescape::EscapeError as EE;
+fn rustc_unescape_error_to_string(err: EscapeError) -> (&'static str, bool) {
+ use rustc_literal_escaper::EscapeError as EE;
#[rustfmt::skip]
let err_message = match err {
@@ -127,7 +127,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
let text = token.text();
// FIXME: lift this lambda refactor to `fn` (https://github.com/rust-lang/rust-analyzer/pull/2834#discussion_r366199205)
- let mut push_err = |prefix_len, off, err: unescape::EscapeError| {
+ let mut push_err = |prefix_len, off, err: EscapeError| {
let off = token.text_range().start() + TextSize::try_from(off + prefix_len).unwrap();
let (message, is_err) = rustc_unescape_error_to_string(err);
// FIXME: Emit lexer warnings