about summary refs log tree commit diff
path: root/compiler/rustc_parse_format/src/lib.rs
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-03-17 05:47:48 -0400
committerGitHub <noreply@github.com>2025-03-17 05:47:48 -0400
commit08dfbf49e30d917c89e49eb14cb3f1e8b8a1c9ef (patch)
tree5b9eb8b49cbc7fb2f7ad05ac4974b36721cef839 /compiler/rustc_parse_format/src/lib.rs
parent10bcdad7df0de3cfb95c7bdb7b16908e73cafc09 (diff)
parent4394f94023526f81b1c45f6e74a17360f31522e4 (diff)
downloadrust-08dfbf49e30d917c89e49eb14cb3f1e8b8a1c9ef.tar.gz
rust-08dfbf49e30d917c89e49eb14cb3f1e8b8a1c9ef.zip
Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu
Add `*_value` methods to proc_macro lib

This is the implementation of https://github.com/rust-lang/libs-team/issues/459.

It allows to get the actual value (unescaped) of the different string literals.

Part of https://github.com/rust-lang/rust/issues/136652.

r? libs-api
Diffstat (limited to 'compiler/rustc_parse_format/src/lib.rs')
-rw-r--r--compiler/rustc_parse_format/src/lib.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs
index 5b8a2fe52d3..5780daf3034 100644
--- a/compiler/rustc_parse_format/src/lib.rs
+++ b/compiler/rustc_parse_format/src/lib.rs
@@ -18,7 +18,6 @@
 pub use Alignment::*;
 pub use Count::*;
 pub use Position::*;
-use rustc_lexer::unescape;
 
 // Note: copied from rustc_span
 /// Range inside of a `Span` used for diagnostics when we only have access to relative positions.
@@ -1094,12 +1093,14 @@ fn find_width_map_from_snippet(
 fn unescape_string(string: &str) -> Option<String> {
     let mut buf = String::new();
     let mut ok = true;
-    unescape::unescape_unicode(string, unescape::Mode::Str, &mut |_, unescaped_char| {
-        match unescaped_char {
+    literal_escaper::unescape_unicode(
+        string,
+        literal_escaper::Mode::Str,
+        &mut |_, unescaped_char| match unescaped_char {
             Ok(c) => buf.push(c),
             Err(_) => ok = false,
-        }
-    });
+        },
+    );
 
     ok.then_some(buf)
 }