We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 04123c2 commit e07045aCopy full SHA for e07045a
library/proc_macro/src/lib.rs
@@ -1355,10 +1355,8 @@ impl Literal {
1355
/// C string literal.
1356
#[unstable(feature = "proc_macro_c_str_literals", issue = "119750")]
1357
pub fn c_string(string: &CStr) -> Literal {
1358
- let quoted = format!("{:?}", string);
1359
- assert!(quoted.starts_with('"') && quoted.ends_with('"'));
1360
- let symbol = "ed[1..quoted.len() - 1];
1361
- Literal::new(bridge::LitKind::CStr, symbol, None)
+ let string = string.to_bytes().escape_ascii().to_string();
+ Literal::new(bridge::LitKind::CStr, &string, None)
1362
}
1363
1364
/// Returns the span encompassing this literal.
0 commit comments