Add tests for checking the impl self type
This commit is contained in:
@@ -3433,6 +3433,20 @@ pub fn baz() -> usize { 31usize }
|
|||||||
assert_eq!("(i32, usize)", type_at_pos(&db, pos));
|
assert_eq!("(i32, usize)", type_at_pos(&db, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn method_resolution_unify_impl_self_type() {
|
||||||
|
let t = type_at(
|
||||||
|
r#"
|
||||||
|
//- /main.rs
|
||||||
|
struct S<T>;
|
||||||
|
impl S<u32> { fn foo(&self) -> u8 {} }
|
||||||
|
impl S<i32> { fn foo(&self) -> i8 {} }
|
||||||
|
fn test() { (S::<u32>.foo(), S::<i32>.foo())<|>; }
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
assert_eq!(t, "(u8, i8)");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn method_resolution_trait_before_autoref() {
|
fn method_resolution_trait_before_autoref() {
|
||||||
let t = type_at(
|
let t = type_at(
|
||||||
|
|||||||
@@ -216,6 +216,39 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_method_completion_only_fitting_impls() {
|
||||||
|
assert_debug_snapshot!(
|
||||||
|
do_ref_completion(
|
||||||
|
r"
|
||||||
|
struct A<T> {}
|
||||||
|
impl A<u32> {
|
||||||
|
fn the_method(&self) {}
|
||||||
|
}
|
||||||
|
impl A<i32> {
|
||||||
|
fn the_other_method(&self) {}
|
||||||
|
}
|
||||||
|
fn foo(a: A<u32>) {
|
||||||
|
a.<|>
|
||||||
|
}
|
||||||
|
",
|
||||||
|
),
|
||||||
|
@r###"
|
||||||
|
[
|
||||||
|
CompletionItem {
|
||||||
|
label: "the_method()",
|
||||||
|
source_range: [243; 243),
|
||||||
|
delete: [243; 243),
|
||||||
|
insert: "the_method()$0",
|
||||||
|
kind: Method,
|
||||||
|
lookup: "the_method",
|
||||||
|
detail: "fn the_method(&self)",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trait_method_completion() {
|
fn test_trait_method_completion() {
|
||||||
assert_debug_snapshot!(
|
assert_debug_snapshot!(
|
||||||
|
|||||||
Reference in New Issue
Block a user