From d47834ee1b8fce7956272e27c9403021940fec8e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jul 2020 18:31:48 +0200 Subject: Guard against infinite macro expansions closes #4463 --- crates/ra_hir_def/src/nameres/tests/macros.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_hir_def/src/nameres/tests') diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/ra_hir_def/src/nameres/tests/macros.rs index 84480d9f6..c52341a07 100644 --- a/crates/ra_hir_def/src/nameres/tests/macros.rs +++ b/crates/ra_hir_def/src/nameres/tests/macros.rs @@ -660,3 +660,27 @@ fn expand_multiple_derive() { ); assert_eq!(map.modules[map.root].scope.impls().len(), 2); } + +#[test] +fn macro_expansion_overflow() { + mark::check!(macro_expansion_overflow); + compute_crate_def_map( + " +macro_rules! a { + ($e:expr; $($t:tt)*) => { + b!($($t)*); + }; + () => {}; +} + +macro_rules! b { + (static = $e:expr; $($t:tt)*) => { + a!($e; $($t)*); + }; + () => {}; +} + +b! { static = #[] (); } +", + ); +} -- cgit v1.2.3