Skip to content

Commit 9ff50d7

Browse files
committed
Move test to hir_ty
1 parent 6d66068 commit 9ff50d7

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

crates/ra_hir_ty/src/tests/regression.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,34 @@ pub mod str {
453453
// should be Option<char>, but currently not because of Chalk ambiguity problem
454454
assert_eq!("(Option<{unknown}>, Option<{unknown}>)", super::type_at_pos(&db, pos));
455455
}
456+
457+
#[test]
458+
fn issue_3642_bad_macro_stackover() {
459+
let (db, pos) = TestDB::with_position(
460+
r#"
461+
//- /main.rs
462+
#[macro_export]
463+
macro_rules! match_ast {
464+
(match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
465+
466+
(match ($node:expr) {
467+
$( ast::$ast:ident($it:ident) => $res:expr, )*
468+
_ => $catch_all:expr $(,)?
469+
}) => {{
470+
$( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
471+
{ $catch_all }
472+
}};
473+
}
474+
475+
fn main() {
476+
let anchor<|> = match_ast! {
477+
match parent {
478+
as => {},
479+
_ => return None
480+
}
481+
};
482+
}"#,
483+
);
484+
485+
assert_eq!("()", super::type_at_pos(&db, pos));
486+
}

crates/ra_ide/src/diagnostics.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -715,34 +715,4 @@ fn main() {
715715
check_struct_shorthand_initialization,
716716
);
717717
}
718-
719-
#[test]
720-
fn test_bad_macro_stackover() {
721-
check_no_diagnostic(
722-
r#"
723-
//- /main.rs
724-
#[macro_export]
725-
macro_rules! match_ast {
726-
(match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
727-
728-
(match ($node:expr) {
729-
$( ast::$ast:ident($it:ident) => $res:expr, )*
730-
_ => $catch_all:expr $(,)?
731-
}) => {{
732-
$( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
733-
{ $catch_all }
734-
}};
735-
}
736-
737-
fn main() {
738-
let anchor = match_ast! {
739-
match parent {
740-
as => {},
741-
_ => return None
742-
}
743-
};
744-
}
745-
"#,
746-
);
747-
}
748718
}

0 commit comments

Comments
 (0)