Skip to content

Commit ed81e34

Browse files
Rollup merge of #139367 - GuillaumeGomez:proc-macro-values, r=Urgau
Add `*_value` methods to proc_macro lib This is the (re-)implementation of rust-lang/libs-team#459. It allows to get the actual value (unescaped) of the different string literals. It was originally done in #136355 but it broke the artifacts build so we decided to move the crate to crates.io to go around this limitation. Part of #136652. Considering this is a copy-paste of the originally approved PR, no need to go through the whole process again. \o/ r? `@Urgau`
2 parents d1da78b + 5797532 commit ed81e34

File tree

25 files changed

+173
-765
lines changed

25 files changed

+173
-765
lines changed

Cargo.lock

+9-1
Original file line numberDiff line numberDiff line change
@@ -3150,6 +3150,12 @@ version = "2.1.1"
31503150
source = "registry+https://github.com/rust-lang/crates.io-index"
31513151
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
31523152

3153+
[[package]]
3154+
name = "rustc-literal-escaper"
3155+
version = "0.0.2"
3156+
source = "registry+https://github.com/rust-lang/crates.io-index"
3157+
checksum = "0041b6238913c41fe704213a4a9329e2f685a156d1781998128b4149c230ad04"
3158+
31533159
[[package]]
31543160
name = "rustc-main"
31553161
version = "0.0.0"
@@ -3242,10 +3248,10 @@ version = "0.0.0"
32423248
dependencies = [
32433249
"bitflags",
32443250
"memchr",
3251+
"rustc-literal-escaper",
32453252
"rustc_ast_ir",
32463253
"rustc_data_structures",
32473254
"rustc_index",
3248-
"rustc_lexer",
32493255
"rustc_macros",
32503256
"rustc_serialize",
32513257
"rustc_span",
@@ -4200,6 +4206,7 @@ name = "rustc_parse"
42004206
version = "0.0.0"
42014207
dependencies = [
42024208
"bitflags",
4209+
"rustc-literal-escaper",
42034210
"rustc_ast",
42044211
"rustc_ast_pretty",
42054212
"rustc_data_structures",
@@ -4222,6 +4229,7 @@ dependencies = [
42224229
name = "rustc_parse_format"
42234230
version = "0.0.0"
42244231
dependencies = [
4232+
"rustc-literal-escaper",
42254233
"rustc_index",
42264234
"rustc_lexer",
42274235
]

compiler/rustc_ast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ edition = "2024"
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
99
memchr = "2.7.4"
10+
rustc-literal-escaper = "0.0.2"
1011
rustc_ast_ir = { path = "../rustc_ast_ir" }
1112
rustc_data_structures = { path = "../rustc_data_structures" }
1213
rustc_index = { path = "../rustc_index" }
13-
rustc_lexer = { path = "../rustc_lexer" }
1414
rustc_macros = { path = "../rustc_macros" }
1515
rustc_serialize = { path = "../rustc_serialize" }
1616
rustc_span = { path = "../rustc_span" }

compiler/rustc_ast/src/util/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{ascii, fmt, str};
44

5-
use rustc_lexer::unescape::{
5+
use rustc_literal_escaper::{
66
MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
77
};
88
use rustc_span::{Span, Symbol, kw, sym};

compiler/rustc_lexer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// tidy-alphabetical-end
2727

2828
mod cursor;
29-
pub mod unescape;
3029

3130
#[cfg(test)]
3231
mod tests;

0 commit comments

Comments
 (0)