mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Test all generic args for trait when finding matching impl
This commit is contained in:
parent
15d4383053
commit
67f1d8fe2c
3 changed files with 158 additions and 64 deletions
|
@ -1834,4 +1834,86 @@ fn f() {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn goto_bin_op_multiple_impl() {
|
||||
check(
|
||||
r#"
|
||||
//- minicore: add
|
||||
struct S;
|
||||
impl core::ops::Add for S {
|
||||
fn add(
|
||||
//^^^
|
||||
) {}
|
||||
}
|
||||
impl core::ops::Add<usize> for S {
|
||||
fn add(
|
||||
) {}
|
||||
}
|
||||
|
||||
fn f() {
|
||||
S +$0 S
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
||||
check(
|
||||
r#"
|
||||
//- minicore: add
|
||||
struct S;
|
||||
impl core::ops::Add for S {
|
||||
fn add(
|
||||
) {}
|
||||
}
|
||||
impl core::ops::Add<usize> for S {
|
||||
fn add(
|
||||
//^^^
|
||||
) {}
|
||||
}
|
||||
|
||||
fn f() {
|
||||
S +$0 0usize
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_call_multiple_trait_impl() {
|
||||
check(
|
||||
r#"
|
||||
trait Trait<T> {
|
||||
fn f(_: T);
|
||||
}
|
||||
impl Trait<i32> for usize {
|
||||
fn f(_: i32) {}
|
||||
//^
|
||||
}
|
||||
impl Trait<i64> for usize {
|
||||
fn f(_: i64) {}
|
||||
}
|
||||
fn main() {
|
||||
usize::f$0(0i32);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
||||
check(
|
||||
r#"
|
||||
trait Trait<T> {
|
||||
fn f(_: T);
|
||||
}
|
||||
impl Trait<i32> for usize {
|
||||
fn f(_: i32) {}
|
||||
}
|
||||
impl Trait<i64> for usize {
|
||||
fn f(_: i64) {}
|
||||
//^
|
||||
}
|
||||
fn main() {
|
||||
usize::f$0(0i64);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue