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 <edwin0cheng@gmail.com>
This commit is contained in:
commit
c412d5f8d1
2 changed files with 24 additions and 1 deletions
|
@ -213,7 +213,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
|
|||
|
||||
// Quote the string
|
||||
// Note that `tt::Literal` expect an escaped string
|
||||
let text = format!("{:?}", text.escape_default().to_string());
|
||||
let text = format!("{:?}", text.escape_debug().to_string());
|
||||
text.into()
|
||||
}
|
||||
|
||||
|
|
|
@ -969,6 +969,29 @@ fn test_meta_doc_comments() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_meta_doc_comments_non_latin() {
|
||||
parse_macro(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($(#[$ i:meta])+) => (
|
||||
$(#[$ i])+
|
||||
fn bar() {}
|
||||
)
|
||||
}
|
||||
"#,
|
||||
).
|
||||
assert_expand_items(
|
||||
r#"foo! {
|
||||
/// 錦瑟無端五十弦,一弦一柱思華年。
|
||||
/**
|
||||
莊生曉夢迷蝴蝶,望帝春心託杜鵑。
|
||||
*/
|
||||
}"#,
|
||||
"# [doc = \" 錦瑟無端五十弦,一弦一柱思華年。\"] # [doc = \"\\\\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\\\\n \"] fn bar () {}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tt_block() {
|
||||
parse_macro(
|
||||
|
|
Loading…
Add table
Reference in a new issue