about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 11:29:26 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-10-10 11:29:26 +0300
commit7e53a3ce23c2ad9c0b92fbc3f5c3a025fa3be6a6 (patch)
treeb1446131dc510a3eb013604da2a0dcc0f80ffc74
parent408475a59329c32766b4e4ad8296b6726e17bfec (diff)
downloadrust-7e53a3ce23c2ad9c0b92fbc3f5c3a025fa3be6a6.tar.gz
rust-7e53a3ce23c2ad9c0b92fbc3f5c3a025fa3be6a6.zip
move test
-rw-r--r--crates/hir_def/src/macro_expansion_tests.rs1
-rw-r--r--crates/hir_def/src/macro_expansion_tests/mbe.rs20
-rw-r--r--crates/mbe/src/tests/expand.rs19
3 files changed, 21 insertions, 19 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs
index c3fb6fc647e..5c0894419c7 100644
--- a/crates/hir_def/src/macro_expansion_tests.rs
+++ b/crates/hir_def/src/macro_expansion_tests.rs
@@ -130,6 +130,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
             (T![&&], _) | (_, T![&&]) => " ",
             (T![,], _) => " ",
             (T![fn], T!['(']) => "",
+            (T![']'], _) if curr_kind.is_keyword() => " ",
             _ if prev_kind.is_keyword() => " ",
             _ => "",
         };
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs
index b4b4ad10ae0..2fe70e9f4fc 100644
--- a/crates/hir_def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs
@@ -936,3 +936,23 @@ fn foo() {
 "#]],
     );
 }
+
+#[test]
+fn test_meta() {
+    check(
+        r#"
+macro_rules! m {
+    ($m:meta) => ( #[$m] fn bar() {} )
+}
+m! { cfg(target_os = "windows") }
+m! { hello::world }
+"#,
+        expect![[r##"
+macro_rules! m {
+    ($m:meta) => ( #[$m] fn bar() {} )
+}
+#[cfg(target_os = "windows")] fn bar() {}
+#[hello::world] fn bar() {}
+"##]],
+    );
+}
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 8fee2420760..79299894429 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -102,25 +102,6 @@ fn test_attr_to_token_tree() {
 }
 
 #[test]
-fn test_meta() {
-    parse_macro(
-        r#"
-        macro_rules! foo {
-            ($ i:meta) => (
-                #[$ i]
-                fn bar() {}
-            )
-        }
-"#,
-    )
-    .assert_expand_items(
-        r#"foo! { cfg(target_os = "windows") }"#,
-        r#"# [cfg (target_os = "windows")] fn bar () {}"#,
-    )
-    .assert_expand_items(r#"foo! { hello::world }"#, r#"# [hello :: world] fn bar () {}"#);
-}
-
-#[test]
 fn test_meta_doc_comments() {
     parse_macro(
         r#"