aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_expand/src/builtin_derive.rs2
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs26
2 files changed, 27 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs
index dae623dd0..cc8c45347 100644
--- a/crates/ra_hir_expand/src/builtin_derive.rs
+++ b/crates/ra_hir_expand/src/builtin_derive.rs
@@ -165,7 +165,7 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: LazyMacroId) -> tt::TokenTree {
165 crates.iter().filter_map(|krate| cg[*krate].display_name.clone()).map(|it| it.to_string()); 165 crates.iter().filter_map(|krate| cg[*krate].display_name.clone()).map(|it| it.to_string());
166 166
167 let tt = if crate_names.any(|name| name == "std" || name == "core") { 167 let tt = if crate_names.any(|name| name == "std" || name == "core") {
168 quote! { krate } 168 quote! { crate }
169 } else { 169 } else {
170 quote! { core } 170 quote! { core }
171 }; 171 };
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
@@ -643,6 +643,32 @@ mod clone {
643} 643}
644 644
645#[test] 645#[test]
646fn infer_derive_clone_in_core() {
647 let (db, pos) = TestDB::with_position(
648 r#"
649//- /main.rs crate:main deps:core
650use core::S;
651fn test() {
652 S.clone()<|>;
653}
654
655//- /lib.rs crate:core
656#[prelude_import]
657use clone::*;
658mod clone {
659 trait Clone {
660 fn clone(&self) -> Self;
661 }
662}
663#[derive(Clone)]
664pub struct S;
665
666"#,
667 );
668 assert_eq!("S", type_at_pos(&db, pos));
669}
670
671#[test]
646fn infer_derive_clone_with_params() { 672fn infer_derive_clone_with_params() {
647 let (db, pos) = TestDB::with_position( 673 let (db, pos) = TestDB::with_position(
648 r#" 674 r#"