File tree 2 files changed +22
-7
lines changed
hir-def/src/macro_expansion_tests
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -1218,8 +1218,10 @@ m! {
1218
1218
macro_rules! m {
1219
1219
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
1220
1220
}
1221
- #[doc = " Single Line Doc 1"]
1222
- #[doc = "\n MultiLines Doc\n "] fn bar() {}
1221
+ #[doc = r" Single Line Doc 1"]
1222
+ #[doc = "
1223
+ MultiLines Doc
1224
+ "] fn bar() {}
1223
1225
"## ] ] ,
1224
1226
) ;
1225
1227
}
@@ -1260,8 +1262,10 @@ m! {
1260
1262
macro_rules! m {
1261
1263
($(#[$ m:meta])+) => ( $(#[$m])+ fn bar() {} )
1262
1264
}
1263
- #[doc = " 錦瑟無端五十弦,一弦一柱思華年。"]
1264
- #[doc = "\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\n "] fn bar() {}
1265
+ #[doc = r" 錦瑟無端五十弦,一弦一柱思華年。"]
1266
+ #[doc = r"
1267
+ 莊生曉夢迷蝴蝶,望帝春心託杜鵑。
1268
+ "] fn bar() {}
1265
1269
"## ] ] ,
1266
1270
) ;
1267
1271
}
@@ -1281,7 +1285,7 @@ m! {
1281
1285
macro_rules! m {
1282
1286
($(#[$m:meta])+) => ( $(#[$m])+ fn bar() {} )
1283
1287
}
1284
- #[doc = " \\ \" \'" ] fn bar() {}
1288
+ #[doc = r# " \ " '"# ] fn bar() {}
1285
1289
"## ] ] ,
1286
1290
) ;
1287
1291
}
Original file line number Diff line number Diff line change @@ -406,9 +406,20 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
406
406
text = & text[ 0 ..text. len ( ) - 2 ] ;
407
407
}
408
408
409
- // Quote the string
409
+ 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
410
421
// Note that `tt::Literal` expect an escaped string
411
- let text = format ! ( "\" {}\" " , text . escape_debug ( ) ) ;
422
+ let text = format ! ( "r{delim} \" {text }\" {delim} " , delim = "#" . repeat ( num_of_hashes ) ) ;
412
423
text. into ( )
413
424
}
414
425
You can’t perform that action at this time.
0 commit comments