diff options
| author | bors <bors@rust-lang.org> | 2023-09-26 03:39:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-26 03:39:25 +0000 |
| commit | a6dce3bac50f14d6ef10f74b82c16e90bdb47d36 (patch) | |
| tree | 445607a7388288de231742aea4ddd3a771dec698 /library | |
| parent | a61f6f3baa01fa52ddf6636f074ed7fe5c50aa7d (diff) | |
| parent | 99a2fa17e684d4f3f625355561e0e8f9a101cc11 (diff) | |
| download | rust-a6dce3bac50f14d6ef10f74b82c16e90bdb47d36.tar.gz rust-a6dce3bac50f14d6ef10f74b82c16e90bdb47d36.zip | |
Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, r=compiler-errors
Properly print cstr literals in `proc_macro::Literal::to_string` Previously we printed the contents of the string, rather than the actual string literal (e.g. `the c string` instead of `c"the c string"`). Fixes #112820 cc #105723
Diffstat (limited to 'library')
| -rw-r--r-- | library/proc_macro/src/lib.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index d322d882cc1..0a70c488aec 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -1418,7 +1418,15 @@ impl Literal { let hashes = get_hashes_str(n); f(&["br", hashes, "\"", symbol, "\"", hashes, suffix]) } - _ => f(&[symbol, suffix]), + bridge::LitKind::CStr => f(&["c\"", symbol, "\"", suffix]), + bridge::LitKind::CStrRaw(n) => { + let hashes = get_hashes_str(n); + f(&["cr", hashes, "\"", symbol, "\"", hashes, suffix]) + } + + bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::Err => { + f(&[symbol, suffix]) + } }) } } |
