about summary refs log tree commit diff
path: root/library/proc_macro
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-09-24 20:05:27 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-09-24 20:05:27 +0000
commit285e574b8ebb10ec329210dbcb1782433555d420 (patch)
tree658a91b17b0ed2f58b1ca7c108dc2f59cf954a88 /library/proc_macro
parent19c65022fc1ad9cc3d3dcf50a0bdf50e4ab572ab (diff)
downloadrust-285e574b8ebb10ec329210dbcb1782433555d420.tar.gz
rust-285e574b8ebb10ec329210dbcb1782433555d420.zip
Fix `.to_string()` of `proc_macro::Literal` (properly print cstr literals)
Diffstat (limited to 'library/proc_macro')
-rw-r--r--library/proc_macro/src/lib.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
index d382fec9352..f08a345db89 100644
--- a/library/proc_macro/src/lib.rs
+++ b/library/proc_macro/src/lib.rs
@@ -1411,7 +1411,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])
+            }
         })
     }
 }