diff options
Diffstat (limited to 'crates/hir_ty/src/tests/macros.rs')
-rw-r--r-- | crates/hir_ty/src/tests/macros.rs | 46 |
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] |
543 | fn infer_builtin_macros_include_str() { | ||
544 | check_types( | ||
545 | r#" | ||
546 | //- /main.rs | ||
547 | #[rustc_builtin_macro] | ||
548 | macro_rules! include_str {() => {}} | ||
549 | |||
550 | fn main() { | ||
551 | let a = include_str!("foo.rs"); | ||
552 | a; | ||
553 | } //^ &str | ||
554 | |||
555 | //- /foo.rs | ||
556 | hello | ||
557 | "#, | ||
558 | ); | ||
559 | } | ||
560 | |||
561 | #[test] | ||
562 | fn infer_builtin_macros_include_str_with_lazy_nested() { | ||
563 | check_types( | ||
564 | r#" | ||
565 | //- /main.rs | ||
566 | #[rustc_builtin_macro] | ||
567 | macro_rules! concat {() => {}} | ||
568 | #[rustc_builtin_macro] | ||
569 | macro_rules! include_str {() => {}} | ||
570 | |||
571 | macro_rules! m { | ||
572 | ($x:expr) => { | ||
573 | concat!("foo", $x) | ||
574 | }; | ||
575 | } | ||
576 | |||
577 | fn main() { | ||
578 | let a = include_str!(m!(".rs")); | ||
579 | a; | ||
580 | } //^ &str | ||
581 | |||
582 | //- /foo.rs | ||
583 | hello | ||
584 | "#, | ||
585 | ); | ||
586 | } | ||
587 | |||
588 | #[test] | ||
543 | #[ignore] | 589 | #[ignore] |
544 | fn include_accidentally_quadratic() { | 590 | fn 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"); |