This commit is contained in:
Edwin Cheng 2020-04-28 02:10:17 +08:00
parent 6a5014329a
commit 213d208e2d
2 changed files with 27 additions and 1 deletions

View file

@ -165,7 +165,7 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: LazyMacroId) -> tt::TokenTree {
crates.iter().filter_map(|krate| cg[*krate].display_name.clone()).map(|it| it.to_string());
let tt = if crate_names.any(|name| name == "std" || name == "core") {
quote! { krate }
quote! { crate }
} else {
quote! { core }
};

View file

@ -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(