Record assoc item resolution
This commit is contained in:
@@ -230,7 +230,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
ty: Ty,
|
ty: Ty,
|
||||||
name: &Name,
|
name: &Name,
|
||||||
_id: ExprOrPatId,
|
id: ExprOrPatId,
|
||||||
) -> Option<(ValueNs, Option<Substs>)> {
|
) -> Option<(ValueNs, Option<Substs>)> {
|
||||||
let krate = self.resolver.krate()?;
|
let krate = self.resolver.krate()?;
|
||||||
|
|
||||||
@@ -276,6 +276,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||||||
trait_: t,
|
trait_: t,
|
||||||
substs: trait_substs,
|
substs: trait_substs,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
self.write_assoc_resolution(id, *item);
|
||||||
return Some((ValueNs::Function(f), Some(substs)));
|
return Some((ValueNs::Function(f), Some(substs)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,6 +390,61 @@ mod tests {
|
|||||||
"spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)",
|
"spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_definition_works_for_ufcs_inherent_methods() {
|
||||||
|
check_goto(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
struct Foo;
|
||||||
|
impl Foo {
|
||||||
|
fn frobnicate() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar(foo: &Foo) {
|
||||||
|
Foo::frobnicate<|>();
|
||||||
|
}
|
||||||
|
",
|
||||||
|
"frobnicate FN_DEF FileId(1) [27; 47) [30; 40)",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_definition_works_for_ufcs_trait_methods_through_traits() {
|
||||||
|
check_goto(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
trait Foo {
|
||||||
|
fn frobnicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
Foo::frobnicate<|>();
|
||||||
|
}
|
||||||
|
",
|
||||||
|
"frobnicate FN_DEF FileId(1) [16; 32) [19; 29)",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn goto_definition_works_for_ufcs_trait_methods_through_self() {
|
||||||
|
check_goto(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
struct Foo;
|
||||||
|
trait Trait {
|
||||||
|
fn frobnicate();
|
||||||
|
}
|
||||||
|
impl Trait for Foo {}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
Foo::frobnicate<|>();
|
||||||
|
}
|
||||||
|
",
|
||||||
|
"frobnicate FN_DEF FileId(1) [30; 46) [33; 43)",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn goto_definition_on_self() {
|
fn goto_definition_on_self() {
|
||||||
check_goto(
|
check_goto(
|
||||||
|
|||||||
Reference in New Issue
Block a user