Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a2fba7c

Browse files
committed
Add test for eager expanding of format_args
1 parent a6e5a91 commit a2fba7c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,40 @@ fn main() {
235235
);
236236
}
237237

238+
#[test]
239+
fn test_format_args_expand_eager() {
240+
check(
241+
r#"
242+
#[rustc_builtin_macro]
243+
macro_rules! concat {}
244+
245+
#[rustc_builtin_macro]
246+
macro_rules! format_args {
247+
($fmt:expr) => ({ /* compiler built-in */ });
248+
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
249+
}
250+
251+
fn main() {
252+
format_args!(concat!("xxx{}y", "{:?}zzz"), 2, b);
253+
}
254+
"#,
255+
expect![[r##"
256+
#[rustc_builtin_macro]
257+
macro_rules! concat {}
258+
259+
#[rustc_builtin_macro]
260+
macro_rules! format_args {
261+
($fmt:expr) => ({ /* compiler built-in */ });
262+
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
263+
}
264+
265+
fn main() {
266+
$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), ]);
267+
}
268+
"##]],
269+
);
270+
}
271+
238272
#[test]
239273
fn test_format_args_expand_with_broken_member_access() {
240274
check(

0 commit comments

Comments
 (0)