aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-17 18:02:28 +0100
committerGitHub <[email protected]>2020-07-17 18:02:28 +0100
commit2777f8c2950f3d204b7ecbf40785fe8fc3523fc1 (patch)
tree86399ce1b6a1a7c190e2817cf942f021ee0af581 /crates/ra_ide_db/src
parentde8c5fc09bdc94dde72ac24c19c8b80a438f0101 (diff)
parentcab360fe3105264f483c4f2b1a33f3d9010e3436 (diff)
Merge #5423
5423: Correctly resolve assoc. types in path bindings r=matklad a=jonas-schievink Previously invoking goto def on `impl Iterator<Item<|> = ()>` would go to `Iterator`, not `Item`. This fixes that. Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r--crates/ra_ide_db/src/defs.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index bcaabca92..e06b189a0 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -254,6 +254,28 @@ pub fn classify_name_ref(
254 } 254 }
255 } 255 }
256 256
257 if ast::AssocTypeArg::cast(parent.clone()).is_some() {
258 // `Trait<Assoc = Ty>`
259 // ^^^^^
260 let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?;
261 let resolved = sema.resolve_path(&path)?;
262 if let PathResolution::Def(ModuleDef::Trait(tr)) = resolved {
263 if let Some(ty) = tr
264 .items(sema.db)
265 .iter()
266 .filter_map(|assoc| match assoc {
267 hir::AssocItem::TypeAlias(it) => Some(*it),
268 _ => None,
269 })
270 .find(|alias| alias.name(sema.db).to_string() == **name_ref.text())
271 {
272 return Some(NameRefClass::Definition(Definition::ModuleDef(
273 ModuleDef::TypeAlias(ty),
274 )));
275 }
276 }
277 }
278
257 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { 279 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) {
258 if let Some(path) = macro_call.path() { 280 if let Some(path) = macro_call.path() {
259 if path.qualifier().is_none() { 281 if path.qualifier().is_none() {