Skip to content

Commit 285e574

Browse files
committed
Fix .to_string() of proc_macro::Literal (properly print cstr literals)
1 parent 19c6502 commit 285e574

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

library/proc_macro/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,15 @@ impl Literal {
14111411
let hashes = get_hashes_str(n);
14121412
f(&["br", hashes, "\"", symbol, "\"", hashes, suffix])
14131413
}
1414-
_ => f(&[symbol, suffix]),
1414+
bridge::LitKind::CStr => f(&["c\"", symbol, "\"", suffix]),
1415+
bridge::LitKind::CStrRaw(n) => {
1416+
let hashes = get_hashes_str(n);
1417+
f(&["cr", hashes, "\"", symbol, "\"", hashes, suffix])
1418+
}
1419+
1420+
bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::Err => {
1421+
f(&[symbol, suffix])
1422+
}
14151423
})
14161424
}
14171425
}

0 commit comments

Comments
 (0)