aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/macros.rs')
-rw-r--r--crates/hir_ty/src/tests/macros.rs46
1 files changed, 46 insertions, 0 deletions
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
@@ -571,6 +571,52 @@ fn bar() -> u32 {0}
571} 571}
572 572
573#[test] 573#[test]
574fn infer_builtin_macros_include_str() {
575 check_types(
576 r#"
577//- /main.rs
578#[rustc_builtin_macro]
579macro_rules! include_str {() => {}}
580
581fn main() {
582 let a = include_str!("foo.rs");
583 a;
584} //^ &str
585
586//- /foo.rs
587hello
588"#,
589 );
590}
591
592#[test]
593fn infer_builtin_macros_include_str_with_lazy_nested() {
594 check_types(
595 r#"
596//- /main.rs
597#[rustc_builtin_macro]
598macro_rules! concat {() => {}}
599#[rustc_builtin_macro]
600macro_rules! include_str {() => {}}
601
602macro_rules! m {
603 ($x:expr) => {
604 concat!("foo", $x)
605 };
606}
607
608fn main() {
609 let a = include_str!(m!(".rs"));
610 a;
611} //^ &str
612
613//- /foo.rs
614hello
615"#,
616 );
617}
618
619#[test]
574#[ignore] 620#[ignore]
575fn include_accidentally_quadratic() { 621fn include_accidentally_quadratic() {
576 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); 622 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic");