From 9ff50d7e839c635632021d47e2dd3982916e4738 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 21 Mar 2020 23:41:07 +0800 Subject: Move test to hir_ty --- crates/ra_hir_ty/src/tests/regression.rs | 31 +++++++++++++++++++++++++++++++ crates/ra_ide/src/diagnostics.rs | 30 ------------------------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 14c8ed3a9..a02e3ee05 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs @@ -453,3 +453,34 @@ pub mod str { // should be Option, but currently not because of Chalk ambiguity problem assert_eq!("(Option<{unknown}>, Option<{unknown}>)", super::type_at_pos(&db, pos)); } + +#[test] +fn issue_3642_bad_macro_stackover() { + let (db, pos) = TestDB::with_position( + 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 + } + }; +}"#, + ); + + assert_eq!("()", super::type_at_pos(&db, pos)); +} diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 50106e31e..a10e642db 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -715,34 +715,4 @@ 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