From 26b9c793f1008e1c5cb1ca61f3c5892f8025f387 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 3 Jan 2021 17:56:59 +0800 Subject: Fixed nested eager macro bug --- crates/hir_ty/src/tests/macros.rs | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crates/hir_ty/src') diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index 23b79abc4..c64f0b5b5 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs @@ -570,6 +570,52 @@ fn bar() -> u32 {0} ); } +#[test] +fn infer_builtin_macros_include_str() { + check_types( + r#" +//- /main.rs +#[rustc_builtin_macro] +macro_rules! include_str {() => {}} + +fn main() { + let a = include_str!("foo.rs"); + a; +} //^ &str + +//- /foo.rs +hello +"#, + ); +} + +#[test] +fn infer_builtin_macros_include_str_with_lazy_nested() { + check_types( + r#" +//- /main.rs +#[rustc_builtin_macro] +macro_rules! concat {() => {}} +#[rustc_builtin_macro] +macro_rules! include_str {() => {}} + +macro_rules! m { + ($x:expr) => { + concat!("foo", $x) + }; +} + +fn main() { + let a = include_str!(m!(".rs")); + a; +} //^ &str + +//- /foo.rs +hello +"#, + ); +} + #[test] #[ignore] fn include_accidentally_quadratic() { -- cgit v1.2.3