From 6a5014329aecf73da81943216729ab64fa255368 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 28 Apr 2020 01:48:55 +0800 Subject: Use core instead of std for builtin derive macros --- crates/ra_hir_ty/src/tests/macros.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 6b5267232..4f82ff702 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -622,14 +622,14 @@ fn main() { fn infer_derive_clone_simple() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core #[derive(Clone)] struct S; fn test() { S.clone()<|>; } -//- /lib.rs crate:std +//- /lib.rs crate:core #[prelude_import] use clone::*; mod clone { @@ -646,7 +646,7 @@ mod clone { fn infer_derive_clone_with_params() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:std +//- /main.rs crate:main deps:core #[derive(Clone)] struct S; #[derive(Clone)] @@ -656,7 +656,7 @@ fn test() { (Wrapper(S).clone(), Wrapper(NonClone).clone())<|>; } -//- /lib.rs crate:std +//- /lib.rs crate:core #[prelude_import] use clone::*; mod clone { -- cgit v1.2.3 From 213d208e2d61576e104a9d5e003efc4ad1abc469 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 28 Apr 2020 02:10:17 +0800 Subject: Add test --- crates/ra_hir_ty/src/tests/macros.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 4f82ff702..ac5485bc9 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -642,6 +642,32 @@ mod clone { assert_eq!("S", type_at_pos(&db, pos)); } +#[test] +fn infer_derive_clone_in_core() { + let (db, pos) = TestDB::with_position( + r#" +//- /main.rs crate:main deps:core +use core::S; +fn test() { + S.clone()<|>; +} + +//- /lib.rs crate:core +#[prelude_import] +use clone::*; +mod clone { + trait Clone { + fn clone(&self) -> Self; + } +} +#[derive(Clone)] +pub struct S; + +"#, + ); + assert_eq!("S", type_at_pos(&db, pos)); +} + #[test] fn infer_derive_clone_with_params() { let (db, pos) = TestDB::with_position( -- cgit v1.2.3 From 6d3b0af900e6cefb507939b311672b7795703461 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 28 Apr 2020 03:32:47 +0800 Subject: Use empty-deps tricks to detect it is core --- crates/ra_hir_ty/src/tests/macros.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index ac5485bc9..5ddecbdc6 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -646,12 +646,6 @@ mod clone { fn infer_derive_clone_in_core() { let (db, pos) = TestDB::with_position( r#" -//- /main.rs crate:main deps:core -use core::S; -fn test() { - S.clone()<|>; -} - //- /lib.rs crate:core #[prelude_import] use clone::*; @@ -663,6 +657,11 @@ mod clone { #[derive(Clone)] pub struct S; +//- /main.rs crate:main deps:core +use core::S; +fn test() { + S.clone()<|>; +} "#, ); assert_eq!("S", type_at_pos(&db, pos)); -- cgit v1.2.3