diff options
author | Edwin Cheng <[email protected]> | 2020-03-06 14:58:45 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-06 14:58:45 +0000 |
commit | 0a06c7e6e6d4f59cacc22b9c1d3122b3faecb62d (patch) | |
tree | 5c5e3a5c60737ed2166ca8b995d08b14c1713fc9 /crates/ra_hir_ty/src | |
parent | d75577fcee79aac06bdddb01fde431f26432c36c (diff) |
Implment include macro
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 5d0efa0f4..42814941f 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -439,6 +439,51 @@ fn main() { | |||
439 | } | 439 | } |
440 | 440 | ||
441 | #[test] | 441 | #[test] |
442 | fn infer_builtin_macros_include() { | ||
443 | let (db, pos) = TestDB::with_position( | ||
444 | r#" | ||
445 | //- /main.rs | ||
446 | #[rustc_builtin_macro] | ||
447 | macro_rules! include {() => {}} | ||
448 | |||
449 | include!("foo.rs"); | ||
450 | |||
451 | fn main() { | ||
452 | bar()<|>; | ||
453 | } | ||
454 | |||
455 | //- /foo.rs | ||
456 | fn bar() -> u32 {0} | ||
457 | "#, | ||
458 | ); | ||
459 | assert_eq!("u32", type_at_pos(&db, pos)); | ||
460 | } | ||
461 | |||
462 | #[test] | ||
463 | fn infer_builtin_macros_include_concat() { | ||
464 | let (db, pos) = TestDB::with_position( | ||
465 | r#" | ||
466 | //- /main.rs | ||
467 | #[rustc_builtin_macro] | ||
468 | macro_rules! include {() => {}} | ||
469 | |||
470 | #[rustc_builtin_macro] | ||
471 | macro_rules! concat {() => {}} | ||
472 | |||
473 | include!(concat!("f", "oo.rs")); | ||
474 | |||
475 | fn main() { | ||
476 | bar()<|>; | ||
477 | } | ||
478 | |||
479 | //- /foo.rs | ||
480 | fn bar() -> u32 {0} | ||
481 | "#, | ||
482 | ); | ||
483 | assert_eq!("u32", type_at_pos(&db, pos)); | ||
484 | } | ||
485 | |||
486 | #[test] | ||
442 | fn infer_builtin_macros_concat_with_lazy() { | 487 | fn infer_builtin_macros_concat_with_lazy() { |
443 | assert_snapshot!( | 488 | assert_snapshot!( |
444 | infer(r#" | 489 | infer(r#" |