diff options
| author | Marijn Schouten <mhkbst@gmail.com> | 2025-03-07 11:17:39 +0000 |
|---|---|---|
| committer | Marijn Schouten <mhkbst@gmail.com> | 2025-06-23 06:36:22 +0000 |
| commit | 707a6f54631c322e8c8ccff363fe024d67d93aa2 (patch) | |
| tree | 3c3069e7ac8e66e87f9661e083beb4020fffcd6a /library | |
| parent | 68ac5abb067806a88464ddbfbd3c7eec877b488d (diff) | |
| download | rust-707a6f54631c322e8c8ccff363fe024d67d93aa2.tar.gz rust-707a6f54631c322e8c8ccff363fe024d67d93aa2.zip | |
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing
Diffstat (limited to 'library')
| -rw-r--r-- | library/Cargo.lock | 5 | ||||
| -rw-r--r-- | library/Cargo.toml | 3 | ||||
| -rw-r--r-- | library/proc_macro/Cargo.toml | 2 | ||||
| -rw-r--r-- | library/proc_macro/src/lib.rs | 13 |
4 files changed, 11 insertions, 12 deletions
diff --git a/library/Cargo.lock b/library/Cargo.lock index 1bd97e7b527..522a81325fb 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -273,10 +273,11 @@ dependencies = [ [[package]] name = "rustc-literal-escaper" -version = "0.0.2" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0041b6238913c41fe704213a4a9329e2f685a156d1781998128b4149c230ad04" +checksum = "ab03008eb631b703dd16978282ae36c73282e7922fe101a4bd072a40ecea7b8b" dependencies = [ + "rustc-std-workspace-core", "rustc-std-workspace-std", ] diff --git a/library/Cargo.toml b/library/Cargo.toml index 35480b9319d..2fbc0775c32 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -45,8 +45,7 @@ rustc-demangle.debug = 0 rustc-demangle.opt-level = "s" [patch.crates-io] -# See comments in `library/rustc-std-workspace-core/README.md` for what's going on -# here +# See comments in `library/rustc-std-workspace-core/README.md` for what's going on here rustc-std-workspace-core = { path = 'rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'rustc-std-workspace-std' } diff --git a/library/proc_macro/Cargo.toml b/library/proc_macro/Cargo.toml index 1d79246356a..8ea92088a84 100644 --- a/library/proc_macro/Cargo.toml +++ b/library/proc_macro/Cargo.toml @@ -9,7 +9,7 @@ std = { path = "../std" } # `core` when resolving doc links. Without this line a different `core` will be # loaded from sysroot causing duplicate lang items and other similar errors. core = { path = "../core" } -rustc-literal-escaper = { version = "0.0.2", features = ["rustc-dep-of-std"] } +rustc-literal-escaper = { version = "0.0.4", features = ["rustc-dep-of-std"] } [features] default = ["rustc-dep-of-std"] diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 32c306be94e..652aa05d6f1 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -55,7 +55,7 @@ use std::{error, fmt}; pub use diagnostic::{Diagnostic, Level, MultiSpan}; #[unstable(feature = "proc_macro_value", issue = "136652")] pub use rustc_literal_escaper::EscapeError; -use rustc_literal_escaper::{MixedUnit, Mode, byte_from_char, unescape_mixed, unescape_unicode}; +use rustc_literal_escaper::{MixedUnit, unescape_byte_str, unescape_c_str, unescape_str}; #[unstable(feature = "proc_macro_totokens", issue = "130977")] pub use to_tokens::ToTokens; @@ -1439,10 +1439,9 @@ impl Literal { // Force-inlining here is aggressive but the closure is // called on every char in the string, so it can be hot in // programs with many long strings containing escapes. - unescape_unicode( + unescape_str( symbol, - Mode::Str, - &mut #[inline(always)] + #[inline(always)] |_, c| match c { Ok(c) => buf.push(c), Err(err) => { @@ -1471,7 +1470,7 @@ impl Literal { let mut error = None; let mut buf = Vec::with_capacity(symbol.len()); - unescape_mixed(symbol, Mode::CStr, &mut |_span, c| match c { + unescape_c_str(symbol, |_span, c| match c { Ok(MixedUnit::Char(c)) => { buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes()) } @@ -1510,8 +1509,8 @@ impl Literal { let mut buf = Vec::with_capacity(symbol.len()); let mut error = None; - unescape_unicode(symbol, Mode::ByteStr, &mut |_, c| match c { - Ok(c) => buf.push(byte_from_char(c)), + unescape_byte_str(symbol, |_, res| match res { + Ok(b) => buf.push(b), Err(err) => { if err.is_fatal() { error = Some(ConversionErrorKind::FailedToUnescape(err)); |
