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 a7656b864..1953da7be 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -540,6 +540,52 @@ fn bar() -> u32 {0}
540} 540}
541 541
542#[test] 542#[test]
543fn infer_builtin_macros_include_str() {
544 check_types(
545 r#"
546//- /main.rs
547#[rustc_builtin_macro]
548macro_rules! include_str {() => {}}
549
550fn main() {
551 let a = include_str!("foo.rs");
552 a;
553} //^ &str
554
555//- /foo.rs
556hello
557"#,
558 );
559}
560
561#[test]
562fn infer_builtin_macros_include_str_with_lazy_nested() {
563 check_types(
564 r#"
565//- /main.rs
566#[rustc_builtin_macro]
567macro_rules! concat {() => {}}
568#[rustc_builtin_macro]
569macro_rules! include_str {() => {}}
570
571macro_rules! m {
572 ($x:expr) => {
573 concat!("foo", $x)
574 };
575}
576
577fn main() {
578 let a = include_str!(m!(".rs"));
579 a;
580} //^ &str
581
582//- /foo.rs
583hello
584"#,
585 );
586}
587
588#[test]
543#[ignore] 589#[ignore]
544fn include_accidentally_quadratic() { 590fn include_accidentally_quadratic() {
545 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); 591 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic");