mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 10:58:02 +00:00
Remove usage of rustc_lexer::unescape in rust-analyzer
This commit is contained in:
parent
7671097ff6
commit
f2ac210f0c
7 changed files with 21 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue