mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 20:35:09 +00:00
Add test
This commit is contained in:
parent
6a5014329a
commit
213d208e2d
2 changed files with 27 additions and 1 deletions
|
@ -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());
|
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") {
|
let tt = if crate_names.any(|name| name == "std" || name == "core") {
|
||||||
quote! { krate }
|
quote! { crate }
|
||||||
} else {
|
} else {
|
||||||
quote! { core }
|
quote! { core }
|
||||||
};
|
};
|
||||||
|
|
|
@ -642,6 +642,32 @@ mod clone {
|
||||||
assert_eq!("S", type_at_pos(&db, pos));
|
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]
|
#[test]
|
||||||
fn infer_derive_clone_with_params() {
|
fn infer_derive_clone_with_params() {
|
||||||
let (db, pos) = TestDB::with_position(
|
let (db, pos) = TestDB::with_position(
|
||||||
|
|
Loading…
Reference in a new issue