about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_def/src/macro_expansion_tests.rs1
-rw-r--r--crates/hir_def/src/macro_expansion_tests/builtin.rs121
-rw-r--r--crates/hir_expand/src/builtin_macro.rs76
3 files changed, 122 insertions, 76 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests.rs b/crates/hir_def/src/macro_expansion_tests.rs
index 7d9d7f39d05..9c91ea8a7ab 100644
--- a/crates/hir_def/src/macro_expansion_tests.rs
+++ b/crates/hir_def/src/macro_expansion_tests.rs
@@ -10,6 +10,7 @@
 //! and harder to understand.
 
 mod mbe;
+mod builtin;
 
 use std::{iter, ops::Range};
 
diff --git a/crates/hir_def/src/macro_expansion_tests/builtin.rs b/crates/hir_def/src/macro_expansion_tests/builtin.rs
new file mode 100644
index 00000000000..c2b900b9df3
--- /dev/null
+++ b/crates/hir_def/src/macro_expansion_tests/builtin.rs
@@ -0,0 +1,121 @@
+//! Tests for builtin macros (see `builtin_macro.rs` in `hir_expand`).
+
+use expect_test::expect;
+
+use crate::macro_expansion_tests::check;
+
+#[test]
+fn test_column_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! column {() => {}}
+
+fn main() { column!(); }
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! column {() => {}}
+
+fn main() { 0; }
+"##]],
+    );
+}
+
+#[test]
+fn test_line_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! line {() => {}}
+
+fn main() { line!() }
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! line {() => {}}
+
+fn main() { 0 }
+"##]],
+    );
+}
+
+#[test]
+fn test_stringify_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! stringify {() => {}}
+
+fn main() {
+    stringify!(
+        a
+        b
+        c
+    );
+}
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! stringify {() => {}}
+
+fn main() {
+    "a b c";
+}
+"##]],
+    );
+}
+
+#[test]
+fn test_env_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! env {() => {}}
+
+fn main() { env!("TEST_ENV_VAR"); }
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! env {() => {}}
+
+fn main() { "__RA_UNIMPLEMENTED__"; }
+"##]],
+    );
+}
+
+#[test]
+fn test_option_env_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! option_env {() => {}}
+
+fn main() { option_env!("TEST_ENV_VAR"); }
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! option_env {() => {}}
+
+fn main() { std::option::Option::None:: < &str>; }
+"##]],
+    );
+}
+
+#[test]
+fn test_file_expand() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! file {() => {}}
+
+fn main() { file!(); }
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! file {() => {}}
+
+fn main() { ""; }
+"##]],
+    );
+}
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index a4ddafbf7af..55dc665c5d7 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -670,82 +670,6 @@ mod tests {
     }
 
     #[test]
-    fn test_column_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! column {() => {}}
-            column!()
-            "#,
-            expect![["0"]],
-        );
-    }
-
-    #[test]
-    fn test_line_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! line {() => {}}
-            line!()
-            "#,
-            expect![["0"]],
-        );
-    }
-
-    #[test]
-    fn test_stringify_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! stringify {() => {}}
-            stringify!(
-                a
-                b
-                c
-            )
-            "#,
-            expect![["\"a b c\""]],
-        );
-    }
-
-    #[test]
-    fn test_env_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! env {() => {}}
-            env!("TEST_ENV_VAR")
-            "#,
-            expect![["\"__RA_UNIMPLEMENTED__\""]],
-        );
-    }
-
-    #[test]
-    fn test_option_env_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! option_env {() => {}}
-            option_env!("TEST_ENV_VAR")
-            "#,
-            expect![["std::option::Option::None:: < &str>"]],
-        );
-    }
-
-    #[test]
-    fn test_file_expand() {
-        check_expansion(
-            r#"
-            #[rustc_builtin_macro]
-            macro_rules! file {() => {}}
-            file!()
-            "#,
-            expect![[r#""""#]],
-        );
-    }
-
-    #[test]
     fn test_assert_expand() {
         check_expansion(
             r#"