aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-25 14:33:07 +0100
committerGitHub <[email protected]>2021-05-25 14:33:07 +0100
commit35db5e99f6f982f4257e88d13cbecca250b05efe (patch)
tree3ee52859ea2d4c288e08841999f61d317ac59476 /crates
parent33fdd512e318f86ccd66b84ce6128c03eb44cf77 (diff)
parent0292efd363584fc4be50b1b1240fbbe990e2ebf1 (diff)
Merge #8990
8990: feat: Also do goto implementation on assoc consts r=lnicola a=lf- 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. Co-authored-by: Jade <[email protected]>
Diffstat (limited to 'crates')
-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}