Skip to content

Commit 39f6ede

Browse files
committed
update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing
1 parent 871de6e commit 39f6ede

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ rustc-demangle.debug = 0
4545
rustc-demangle.opt-level = "s"
4646

4747
[patch.crates-io]
48-
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
49-
# here
48+
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on here
5049
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
5150
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
5251
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }

proc_macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ std = { path = "../std" }
99
# `core` when resolving doc links. Without this line a different `core` will be
1010
# loaded from sysroot causing duplicate lang items and other similar errors.
1111
core = { path = "../core" }
12-
rustc-literal-escaper = { version = "0.0.2", features = ["rustc-dep-of-std"] }
12+
rustc-literal-escaper = { version = "0.0.4", features = ["rustc-dep-of-std"] }
1313

1414
[features]
1515
default = ["rustc-dep-of-std"]

proc_macro/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use std::{error, fmt};
5555
pub use diagnostic::{Diagnostic, Level, MultiSpan};
5656
#[unstable(feature = "proc_macro_value", issue = "136652")]
5757
pub use rustc_literal_escaper::EscapeError;
58-
use rustc_literal_escaper::{MixedUnit, Mode, byte_from_char, unescape_mixed, unescape_unicode};
58+
use rustc_literal_escaper::{MixedUnit, unescape_byte_str, unescape_c_str, unescape_str};
5959
#[unstable(feature = "proc_macro_totokens", issue = "130977")]
6060
pub use to_tokens::ToTokens;
6161

@@ -1439,10 +1439,9 @@ impl Literal {
14391439
// Force-inlining here is aggressive but the closure is
14401440
// called on every char in the string, so it can be hot in
14411441
// programs with many long strings containing escapes.
1442-
unescape_unicode(
1442+
unescape_str(
14431443
symbol,
1444-
Mode::Str,
1445-
&mut #[inline(always)]
1444+
#[inline(always)]
14461445
|_, c| match c {
14471446
Ok(c) => buf.push(c),
14481447
Err(err) => {
@@ -1471,7 +1470,7 @@ impl Literal {
14711470
let mut error = None;
14721471
let mut buf = Vec::with_capacity(symbol.len());
14731472

1474-
unescape_mixed(symbol, Mode::CStr, &mut |_span, c| match c {
1473+
unescape_c_str(symbol, |_span, c| match c {
14751474
Ok(MixedUnit::Char(c)) => {
14761475
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
14771476
}
@@ -1510,8 +1509,8 @@ impl Literal {
15101509
let mut buf = Vec::with_capacity(symbol.len());
15111510
let mut error = None;
15121511

1513-
unescape_unicode(symbol, Mode::ByteStr, &mut |_, c| match c {
1514-
Ok(c) => buf.push(byte_from_char(c)),
1512+
unescape_byte_str(symbol, |_, res| match res {
1513+
Ok(b) => buf.push(b),
15151514
Err(err) => {
15161515
if err.is_fatal() {
15171516
error = Some(ConversionErrorKind::FailedToUnescape(err));

0 commit comments

Comments
 (0)