From e1a9461806a4d6dd2ad58be2d6148c0e8fdb2299 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 21 Mar 2020 22:43:48 +0800 Subject: Add identity expansion checking --- crates/ra_ide/src/diagnostics.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index a10e642db..50106e31e 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -715,4 +715,34 @@ fn main() { check_struct_shorthand_initialization, ); } + + #[test] + fn test_bad_macro_stackover() { + check_no_diagnostic( + r#" + //- /main.rs + #[macro_export] + macro_rules! match_ast { + (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) }; + + (match ($node:expr) { + $( ast::$ast:ident($it:ident) => $res:expr, )* + _ => $catch_all:expr $(,)? + }) => {{ + $( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )* + { $catch_all } + }}; + } + + fn main() { + let anchor = match_ast! { + match parent { + as => {}, + _ => return None + } + }; + } + "#, + ); + } } -- cgit v1.2.3