diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-01-31 15:02:41 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-02-10 10:38:22 +0100 |
| commit | 49d2d5a1161720ccd5b76ac2afbdceb6ea7e2e6e (patch) | |
| tree | a35c22c0561de96030e09c1210aedf7fcb609540 /compiler/rustc_parse_format | |
| parent | c03c38d5c2368cd2aa0e056dba060b94fc747f4e (diff) | |
| download | rust-49d2d5a1161720ccd5b76ac2afbdceb6ea7e2e6e.tar.gz rust-49d2d5a1161720ccd5b76ac2afbdceb6ea7e2e6e.zip | |
Extract `unescape` from `rustc_lexer` into its own crate
Diffstat (limited to 'compiler/rustc_parse_format')
| -rw-r--r-- | compiler/rustc_parse_format/Cargo.toml | 1 | ||||
| -rw-r--r-- | compiler/rustc_parse_format/src/lib.rs | 11 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_parse_format/Cargo.toml b/compiler/rustc_parse_format/Cargo.toml index 707c4e31847..51ea46f4c9b 100644 --- a/compiler/rustc_parse_format/Cargo.toml +++ b/compiler/rustc_parse_format/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] # tidy-alphabetical-start +literal-escaper = { path = "../../library/literal-escaper" } rustc_index = { path = "../rustc_index", default-features = false } rustc_lexer = { path = "../rustc_lexer" } # tidy-alphabetical-end diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 3b985621b57..7e89f9b079b 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -19,7 +19,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. @@ -1095,12 +1094,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) } |
