aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-07 11:09:54 +0000
committerGitHub <[email protected]>2020-03-07 11:09:54 +0000
commit013e9080564aa497e6de92ae4bd1f162328b3cd8 (patch)
treef6d9895dc110a963f147dee9140775853412fd30 /crates/ra_hir_ty
parent919747c323359724b3b451a43ed82152014c73de (diff)
parent18f88ad10bed9f8d82a3a67c2bb9eb23995641a0 (diff)
Merge #3509
3509: Prevent include! macro include itself r=matklad a=edwin0cheng This PR prevent `include` macro including itself. Note: It **does not** prevent a cyclic include: ```rust // foo.rs include!("bar.rs") // bar.rs include!("foo.rs") ``` Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index c86733ac3..ffa78b046 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -511,6 +511,24 @@ fn bar() -> u32 {0}
511} 511}
512 512
513#[test] 513#[test]
514fn infer_builtin_macros_include_itself_should_failed() {
515 let (db, pos) = TestDB::with_position(
516 r#"
517//- /main.rs
518#[rustc_builtin_macro]
519macro_rules! include {() => {}}
520
521include!("main.rs");
522
523fn main() {
524 0<|>
525}
526"#,
527 );
528 assert_eq!("i32", type_at_pos(&db, pos));
529}
530
531#[test]
514fn infer_builtin_macros_concat_with_lazy() { 532fn infer_builtin_macros_concat_with_lazy() {
515 assert_snapshot!( 533 assert_snapshot!(
516 infer(r#" 534 infer(r#"