about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhkalbasi <hamidrezakalbasi@protonmail.com>2023-05-17 01:15:04 +0330
committerhkalbasi <hamidrezakalbasi@protonmail.com>2023-05-17 01:15:04 +0330
commita2fba7c67ec46afc78701759719ffabf4218ad3d (patch)
treeff845ada38750c074e18074832b9c81eccb3cc21
parenta6e5a912f985278d610482733e3a5bbdfccb3c04 (diff)
downloadrust-a2fba7c67ec46afc78701759719ffabf4218ad3d.tar.gz
rust-a2fba7c67ec46afc78701759719ffabf4218ad3d.zip
Add test for eager expanding of `format_args`
-rw-r--r--crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs b/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs
index 12e01bc69c2..0beab57eb73 100644
--- a/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs
+++ b/crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs
@@ -236,6 +236,40 @@ fn main() {
 }
 
 #[test]
+fn test_format_args_expand_eager() {
+    check(
+        r#"
+#[rustc_builtin_macro]
+macro_rules! concat {}
+
+#[rustc_builtin_macro]
+macro_rules! format_args {
+    ($fmt:expr) => ({ /* compiler built-in */ });
+    ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
+}
+
+fn main() {
+    format_args!(concat!("xxx{}y", "{:?}zzz"), 2, b);
+}
+"#,
+        expect![[r##"
+#[rustc_builtin_macro]
+macro_rules! concat {}
+
+#[rustc_builtin_macro]
+macro_rules! format_args {
+    ($fmt:expr) => ({ /* compiler built-in */ });
+    ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
+}
+
+fn main() {
+    $crate::fmt::Arguments::new_v1(&["xxx", "y", "zzz", ], &[$crate::fmt::ArgumentV1::new(&(2), $crate::fmt::Display::fmt), $crate::fmt::ArgumentV1::new(&(b), $crate::fmt::Debug::fmt), ]);
+}
+"##]],
+    );
+}
+
+#[test]
 fn test_format_args_expand_with_broken_member_access() {
     check(
         r#"