From 0a06c7e6e6d4f59cacc22b9c1d3122b3faecb62d Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 6 Mar 2020 22:58:45 +0800 Subject: Implment include macro --- crates/ra_hir_ty/src/tests/macros.rs | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 5d0efa0f4..42814941f 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -438,6 +438,51 @@ fn main() { ); } +#[test] +fn infer_builtin_macros_include() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs +#[rustc_builtin_macro] +macro_rules! include {() => {}} + +include!("foo.rs"); + +fn main() { + bar()<|>; +} + +//- /foo.rs +fn bar() -> u32 {0} +"#, + ); + assert_eq!("u32", type_at_pos(&db, pos)); +} + +#[test] +fn infer_builtin_macros_include_concat() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs +#[rustc_builtin_macro] +macro_rules! include {() => {}} + +#[rustc_builtin_macro] +macro_rules! concat {() => {}} + +include!(concat!("f", "oo.rs")); + +fn main() { + bar()<|>; +} + +//- /foo.rs +fn bar() -> u32 {0} +"#, + ); + assert_eq!("u32", type_at_pos(&db, pos)); +} + #[test] fn infer_builtin_macros_concat_with_lazy() { assert_snapshot!( -- cgit v1.2.3