We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f663521 commit cfd74e9Copy full SHA for cfd74e9
crates/mbe/src/syntax_bridge.rs
@@ -406,9 +406,20 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
406
text = &text[0..text.len() - 2];
407
}
408
409
- // Quote the string
+ let mut num_of_hashes = 0;
410
+ let mut count = 0;
411
+ for ch in text.chars() {
412
+ count = match ch {
413
+ '"' => 1,
414
+ '#' if count > 0 => count + 1,
415
+ _ => 0,
416
+ };
417
+ num_of_hashes = num_of_hashes.max(count);
418
+ }
419
+
420
+ // Quote raw string with delimiters
421
// Note that `tt::Literal` expect an escaped string
- let text = format!("\"{}\"", text.escape_debug());
422
+ let text = format!("r{delim}\"{text}\"{delim}", delim = "#".repeat(num_of_hashes));
423
text.into()
424
425
0 commit comments