aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs45
-rw-r--r--crates/ra_hir_ty/src/traits.rs2
2 files changed, 46 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 42814941f..ffa78b046 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -484,6 +484,51 @@ fn bar() -> u32 {0}
484} 484}
485 485
486#[test] 486#[test]
487fn infer_builtin_macros_include_concat_with_bad_env_should_failed() {
488 let (db, pos) = TestDB::with_position(
489 r#"
490//- /main.rs
491#[rustc_builtin_macro]
492macro_rules! include {() => {}}
493
494#[rustc_builtin_macro]
495macro_rules! concat {() => {}}
496
497#[rustc_builtin_macro]
498macro_rules! env {() => {}}
499
500include!(concat!(env!("OUT_DIR"), "/foo.rs"));
501
502fn main() {
503 bar()<|>;
504}
505
506//- /foo.rs
507fn bar() -> u32 {0}
508"#,
509 );
510 assert_eq!("{unknown}", type_at_pos(&db, pos));
511}
512
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]
487fn infer_builtin_macros_concat_with_lazy() { 532fn infer_builtin_macros_concat_with_lazy() {
488 assert_snapshot!( 533 assert_snapshot!(
489 infer(r#" 534 infer(r#"
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 8de588790..6e1c8e42a 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -47,7 +47,7 @@ pub(crate) fn impls_for_trait_query(
47 // will only ever get called for a few crates near the root of the tree (the 47 // will only ever get called for a few crates near the root of the tree (the
48 // ones the user is editing), so this may actually be a waste of memory. I'm 48 // ones the user is editing), so this may actually be a waste of memory. I'm
49 // doing it like this mainly for simplicity for now. 49 // doing it like this mainly for simplicity for now.
50 for dep in db.crate_graph().dependencies(krate) { 50 for dep in &db.crate_graph()[krate].dependencies {
51 impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter()); 51 impls.extend(db.impls_for_trait(dep.crate_id, trait_).iter());
52 } 52 }
53 let crate_impl_defs = db.impls_in_crate(krate); 53 let crate_impl_defs = db.impls_in_crate(krate);