From 34dc8d25c1e461cc311d6d4404f74502513cd3ae Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 18 Mar 2020 17:47:59 +0800 Subject: Add basic custom derive lowering --- crates/ra_hir_ty/src/tests/macros.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/macros.rs') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 2e309a379..d59e4eea6 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -639,3 +639,26 @@ mod clone { ); assert_eq!("(Wrapper, {unknown})", type_at_pos(&db, pos)); } + +#[test] +fn infer_custom_derive_simple() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs crate:main deps:foo +use foo::Foo; + +#[derive(Foo)] +struct S{} + +fn test() { + S{}<|>; +} + +//- /lib.rs crate:foo +#[proc_macro_derive(Foo)] +pub fn derive_foo(_item: TokenStream) -> TokenStream { +} +"#, + ); + assert_eq!("S", type_at_pos(&db, pos)); +} -- cgit v1.2.3 From 5bd3aa05d6963a633a1b5cea8187500657847b21 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 24 Mar 2020 04:18:15 +0800 Subject: Fix trailling whitespace --- crates/ra_hir_ty/src/tests/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/tests/macros.rs') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index d59e4eea6..e3b9fbac5 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -656,7 +656,7 @@ fn test() { //- /lib.rs crate:foo #[proc_macro_derive(Foo)] -pub fn derive_foo(_item: TokenStream) -> TokenStream { +pub fn derive_foo(_item: TokenStream) -> TokenStream { } "#, ); -- cgit v1.2.3 From 2adc9a8d5f8f7686a125a478330c67a2d46fba98 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 25 Mar 2020 20:14:22 +0800 Subject: Remove collect proc_macro definitions --- crates/ra_hir_ty/src/tests/macros.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_ty/src/tests/macros.rs') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index e3b9fbac5..eb97288f1 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -642,9 +642,10 @@ mod clone { #[test] fn infer_custom_derive_simple() { + // FIXME: this test current now do nothing let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:foo +//- /main.rs crate:main use foo::Foo; #[derive(Foo)] @@ -653,11 +654,6 @@ struct S{} fn test() { S{}<|>; } - -//- /lib.rs crate:foo -#[proc_macro_derive(Foo)] -pub fn derive_foo(_item: TokenStream) -> TokenStream { -} "#, ); assert_eq!("S", type_at_pos(&db, pos)); -- cgit v1.2.3