From 18f88ad10bed9f8d82a3a67c2bb9eb23995641a0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 7 Mar 2020 16:25:43 +0800 Subject: Prevent include! macro include itself --- crates/ra_hir_ty/src/tests/macros.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index c86733ac3..ffa78b046 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -510,6 +510,24 @@ fn bar() -> u32 {0} assert_eq!("{unknown}", type_at_pos(&db, pos)); } +#[test] +fn infer_builtin_macros_include_itself_should_failed() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs +#[rustc_builtin_macro] +macro_rules! include {() => {}} + +include!("main.rs"); + +fn main() { + 0<|> +} +"#, + ); + assert_eq!("i32", type_at_pos(&db, pos)); +} + #[test] fn infer_builtin_macros_concat_with_lazy() { assert_snapshot!( -- cgit v1.2.3