aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-03-07 04:53:40 +0000
committerEdwin Cheng <[email protected]>2020-03-07 04:53:40 +0000
commit36c768468729653079ed5c00e759bd12cd02e241 (patch)
tree2ff86b86deec88a48084e8e8fa158afc02ae46a2
parent48bb1c51721b7736b6d6f2e5cb82126c91934433 (diff)
Use a not so dummy implementation of env macro
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs2
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs27
2 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index 9fc33e4b1..51d54331e 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -142,7 +142,7 @@ fn env_expand(
142 _tt: &tt::Subtree, 142 _tt: &tt::Subtree,
143) -> Result<tt::Subtree, mbe::ExpandError> { 143) -> Result<tt::Subtree, mbe::ExpandError> {
144 // dummy implementation for type-checking purposes 144 // dummy implementation for type-checking purposes
145 let expanded = quote! { "" }; 145 let expanded = quote! { "__RA_UNIMPLEMENTATED__" };
146 146
147 Ok(expanded) 147 Ok(expanded)
148} 148}
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 42814941f..c86733ac3 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -484,6 +484,33 @@ 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]
487fn infer_builtin_macros_concat_with_lazy() { 514fn infer_builtin_macros_concat_with_lazy() {
488 assert_snapshot!( 515 assert_snapshot!(
489 infer(r#" 516 infer(r#"