aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/goto_implementation.rs
diff options
context:
space:
mode:
authorJade <[email protected]>2021-05-25 14:27:41 +0100
committerJade <[email protected]>2021-05-25 14:27:41 +0100
commit0292efd363584fc4be50b1b1240fbbe990e2ebf1 (patch)
tree9b952f814b4733f287ea9f5fb3f9bc412514a923 /crates/ide/src/goto_implementation.rs
parentf3cfd8afb6db1ee0a8449655703172a0c8cf5411 (diff)
Also do goto implementation on assoc consts
I forgot to put this into #8988, sorry. Goto implementation on a const on the trait will go to the implementations with their respective definitions of the const, if present.
Diffstat (limited to 'crates/ide/src/goto_implementation.rs')
-rw-r--r--crates/ide/src/goto_implementation.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs
index 5a8d3c3f9..43356a94e 100644
--- a/crates/ide/src/goto_implementation.rs
+++ b/crates/ide/src/goto_implementation.rs
@@ -53,7 +53,13 @@ pub(crate) fn goto_implementation(
53 let assoc = f.as_assoc_item(sema.db)?; 53 let assoc = f.as_assoc_item(sema.db)?;
54 let name = assoc.name(sema.db)?; 54 let name = assoc.name(sema.db)?;
55 let trait_ = assoc.containing_trait(sema.db)?; 55 let trait_ = assoc.containing_trait(sema.db)?;
56 impls_for_trait_fn(&sema, trait_, name) 56 impls_for_trait_item(&sema, trait_, name)
57 }
58 hir::ModuleDef::Const(c) => {
59 let assoc = c.as_assoc_item(sema.db)?;
60 let name = assoc.name(sema.db)?;
61 let trait_ = assoc.containing_trait(sema.db)?;
62 impls_for_trait_item(&sema, trait_, name)
57 } 63 }
58 _ => return None, 64 _ => return None,
59 }; 65 };
@@ -71,7 +77,7 @@ fn impls_for_trait(sema: &Semantics<RootDatabase>, trait_: hir::Trait) -> Vec<Na
71 .collect() 77 .collect()
72} 78}
73 79
74fn impls_for_trait_fn( 80fn impls_for_trait_item(
75 sema: &Semantics<RootDatabase>, 81 sema: &Semantics<RootDatabase>,
76 trait_: hir::Trait, 82 trait_: hir::Trait,
77 fun_name: hir::Name, 83 fun_name: hir::Name,
@@ -306,4 +312,22 @@ impl Tr for S {
306"#, 312"#,
307 ); 313 );
308 } 314 }
315
316 #[test]
317 fn goto_implementation_trait_assoc_const() {
318 check(
319 r#"
320trait Tr {
321 const C$0: usize;
322}
323
324struct S;
325
326impl Tr for S {
327 const C: usize = 4;
328 //^
329}
330"#,
331 );
332 }
309} 333}