Skip to content

Commit c412d5f

Browse files
Merge #7803
7803: Fix non-latin characters doc comment in mbe expansion r=edwin0cheng a=edwin0cheng Fixes #7781 ![Peek 2021-02-28 13-47](https://user-images.githubusercontent.com/11014119/109409237-f58e5580-79cb-11eb-92ed-a6700bbe39b5.gif) Off-topic: This is a [beautiful poem](http://chinesepoetryinenglishverse.blogspot.com/2013/12/blog-post_4784.html) from by Li Shangyin. bors r+ Co-authored-by: Edwin Cheng <[email protected]>
2 parents e0437f8 + bf8bc5c commit c412d5f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

crates/mbe/src/syntax_bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
213213

214214
// Quote the string
215215
// Note that `tt::Literal` expect an escaped string
216-
let text = format!("{:?}", text.escape_default().to_string());
216+
let text = format!("{:?}", text.escape_debug().to_string());
217217
text.into()
218218
}
219219

crates/mbe/src/tests.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,29 @@ fn test_meta_doc_comments() {
969969
);
970970
}
971971

972+
#[test]
973+
fn test_meta_doc_comments_non_latin() {
974+
parse_macro(
975+
r#"
976+
macro_rules! foo {
977+
($(#[$ i:meta])+) => (
978+
$(#[$ i])+
979+
fn bar() {}
980+
)
981+
}
982+
"#,
983+
).
984+
assert_expand_items(
985+
r#"foo! {
986+
/// 錦瑟無端五十弦,一弦一柱思華年。
987+
/**
988+
莊生曉夢迷蝴蝶,望帝春心託杜鵑。
989+
*/
990+
}"#,
991+
"# [doc = \" 錦瑟無端五十弦,一弦一柱思華年。\"] # [doc = \"\\\\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\\\\n \"] fn bar () {}",
992+
);
993+
}
994+
972995
#[test]
973996
fn test_tt_block() {
974997
parse_macro(

0 commit comments

Comments
 (0)