diff options
Diffstat (limited to 'crates/hir_ty/src/tests/macros.rs')
-rw-r--r-- | crates/hir_ty/src/tests/macros.rs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index a7656b864..c64f0b5b5 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs | |||
@@ -371,6 +371,37 @@ expand!(); | |||
371 | } | 371 | } |
372 | 372 | ||
373 | #[test] | 373 | #[test] |
374 | fn infer_macro_with_dollar_crate_in_def_site() { | ||
375 | check_types( | ||
376 | r#" | ||
377 | //- /main.rs crate:main deps:foo | ||
378 | use foo::expand; | ||
379 | |||
380 | macro_rules! list { | ||
381 | ($($tt:tt)*) => { $($tt)* } | ||
382 | } | ||
383 | |||
384 | fn test() { | ||
385 | let r = expand!(); | ||
386 | r; | ||
387 | //^ u128 | ||
388 | } | ||
389 | |||
390 | //- /lib.rs crate:foo | ||
391 | #[macro_export] | ||
392 | macro_rules! expand { | ||
393 | () => { list!($crate::m!()) }; | ||
394 | } | ||
395 | |||
396 | #[macro_export] | ||
397 | macro_rules! m { | ||
398 | () => { 0u128 }; | ||
399 | } | ||
400 | "#, | ||
401 | ); | ||
402 | } | ||
403 | |||
404 | #[test] | ||
374 | fn infer_type_value_non_legacy_macro_use_as() { | 405 | fn infer_type_value_non_legacy_macro_use_as() { |
375 | check_infer( | 406 | check_infer( |
376 | r#" | 407 | r#" |
@@ -540,6 +571,52 @@ fn bar() -> u32 {0} | |||
540 | } | 571 | } |
541 | 572 | ||
542 | #[test] | 573 | #[test] |
574 | fn infer_builtin_macros_include_str() { | ||
575 | check_types( | ||
576 | r#" | ||
577 | //- /main.rs | ||
578 | #[rustc_builtin_macro] | ||
579 | macro_rules! include_str {() => {}} | ||
580 | |||
581 | fn main() { | ||
582 | let a = include_str!("foo.rs"); | ||
583 | a; | ||
584 | } //^ &str | ||
585 | |||
586 | //- /foo.rs | ||
587 | hello | ||
588 | "#, | ||
589 | ); | ||
590 | } | ||
591 | |||
592 | #[test] | ||
593 | fn infer_builtin_macros_include_str_with_lazy_nested() { | ||
594 | check_types( | ||
595 | r#" | ||
596 | //- /main.rs | ||
597 | #[rustc_builtin_macro] | ||
598 | macro_rules! concat {() => {}} | ||
599 | #[rustc_builtin_macro] | ||
600 | macro_rules! include_str {() => {}} | ||
601 | |||
602 | macro_rules! m { | ||
603 | ($x:expr) => { | ||
604 | concat!("foo", $x) | ||
605 | }; | ||
606 | } | ||
607 | |||
608 | fn main() { | ||
609 | let a = include_str!(m!(".rs")); | ||
610 | a; | ||
611 | } //^ &str | ||
612 | |||
613 | //- /foo.rs | ||
614 | hello | ||
615 | "#, | ||
616 | ); | ||
617 | } | ||
618 | |||
619 | #[test] | ||
543 | #[ignore] | 620 | #[ignore] |
544 | fn include_accidentally_quadratic() { | 621 | fn include_accidentally_quadratic() { |
545 | let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); | 622 | let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); |