Skip to content

Commit 213d208

Browse files
committed
Add test
1 parent 6a50143 commit 213d208

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

crates/ra_hir_expand/src/builtin_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: LazyMacroId) -> tt::TokenTree {
165165
crates.iter().filter_map(|krate| cg[*krate].display_name.clone()).map(|it| it.to_string());
166166

167167
let tt = if crate_names.any(|name| name == "std" || name == "core") {
168-
quote! { krate }
168+
quote! { crate }
169169
} else {
170170
quote! { core }
171171
};

crates/ra_hir_ty/src/tests/macros.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,32 @@ mod clone {
642642
assert_eq!("S", type_at_pos(&db, pos));
643643
}
644644

645+
#[test]
646+
fn infer_derive_clone_in_core() {
647+
let (db, pos) = TestDB::with_position(
648+
r#"
649+
//- /main.rs crate:main deps:core
650+
use core::S;
651+
fn test() {
652+
S.clone()<|>;
653+
}
654+
655+
//- /lib.rs crate:core
656+
#[prelude_import]
657+
use clone::*;
658+
mod clone {
659+
trait Clone {
660+
fn clone(&self) -> Self;
661+
}
662+
}
663+
#[derive(Clone)]
664+
pub struct S;
665+
666+
"#,
667+
);
668+
assert_eq!("S", type_at_pos(&db, pos));
669+
}
670+
645671
#[test]
646672
fn infer_derive_clone_with_params() {
647673
let (db, pos) = TestDB::with_position(

0 commit comments

Comments
 (0)