diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-06 15:08:41 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-06 15:08:41 +0000 |
commit | aa82b5915de32f582b58cd25816bc3be69aa75c7 (patch) | |
tree | 4c95641a41ee48e120a6d54d2211dda2e70cadb1 /crates/ra_hir_ty/src/tests | |
parent | 4173645a717ab9b7a7d9b2534e3219cacbcfb93a (diff) | |
parent | 0a06c7e6e6d4f59cacc22b9c1d3122b3faecb62d (diff) |
Merge #3494
3494: Implement include macro r=matklad a=edwin0cheng
This PR implement builtin `include` macro.
* It does not support include as expression yet.
* It doesn't consider `env!("OUT_DIR")` yet.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-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#" |