update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing
This commit is contained in:
parent
68ac5abb06
commit
707a6f5463
16 changed files with 67 additions and 94 deletions
|
|
@ -2,6 +2,7 @@ use crate::utils::{
|
|||
ErrAction, File, FileUpdater, RustSearcher, Token, UpdateMode, UpdateStatus, expect_action, update_text_region_fn,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use rustc_lexer::{LiteralKind, TokenKind, tokenize};
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::Write;
|
||||
use std::ops::Range;
|
||||
|
|
@ -342,7 +343,7 @@ fn parse_str_lit(s: &str) -> String {
|
|||
.and_then(|s| s.strip_suffix('"'))
|
||||
.unwrap_or_else(|| panic!("expected quoted string, found `{s}`"));
|
||||
let mut res = String::with_capacity(s.len());
|
||||
rustc_literal_escaper::unescape_unicode(s, mode, &mut |_, ch| {
|
||||
rustc_literal_escaper::unescape_str(s, |range, ch| {
|
||||
if let Ok(ch) = ch {
|
||||
res.push(ch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ description = "A script to extract the lint documentation for the rustc book."
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rustc-literal-escaper = "0.0.2"
|
||||
rustc-literal-escaper = "0.0.4"
|
||||
serde_json = "1.0.57"
|
||||
tempfile = "3.1.0"
|
||||
walkdir = "2.3.1"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::fs;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use rustc_literal_escaper::{Mode, unescape_unicode};
|
||||
use rustc_literal_escaper::unescape_str;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
mod groups;
|
||||
|
|
@ -218,7 +218,7 @@ impl<'a> LintExtractor<'a> {
|
|||
} else if let Some(text) = line.strip_prefix("#[doc = \"") {
|
||||
let escaped = text.strip_suffix("\"]").unwrap();
|
||||
let mut buf = String::new();
|
||||
unescape_unicode(escaped, Mode::Str, &mut |_, c| match c {
|
||||
unescape_str(escaped, |_, res| match res {
|
||||
Ok(c) => buf.push(c),
|
||||
Err(err) => {
|
||||
assert!(!err.is_fatal(), "failed to unescape string literal")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue