diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-28 05:55:06 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-28 05:55:06 +0000 |
commit | c412d5f8d13cd55dc1873fb55e742a317c7846a8 (patch) | |
tree | 6edd57209c4a1099e22585edc1b880f6255ae0cb | |
parent | e0437f899ceea242173c665f7d124c485b680a7a (diff) | |
parent | bf8bc5c882ac4acb5fef4cd7adf50d4233507e83 (diff) |
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]>
-rw-r--r-- | crates/mbe/src/syntax_bridge.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/tests.rs | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index 5a91781fc..aacae1026 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs | |||
@@ -213,7 +213,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr { | |||
213 | 213 | ||
214 | // Quote the string | 214 | // Quote the string |
215 | // Note that `tt::Literal` expect an escaped string | 215 | // 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()); |
217 | text.into() | 217 | text.into() |
218 | } | 218 | } |
219 | 219 | ||
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 1c467facd..f1eadcd1e 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs | |||
@@ -970,6 +970,29 @@ fn test_meta_doc_comments() { | |||
970 | } | 970 | } |
971 | 971 | ||
972 | #[test] | 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 | |||
995 | #[test] | ||
973 | fn test_tt_block() { | 996 | fn test_tt_block() { |
974 | parse_macro( | 997 | parse_macro( |
975 | r#" | 998 | r#" |