aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/defs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/defs.rs')
-rw-r--r--crates/ra_ide_db/src/defs.rs32
1 files changed, 30 insertions, 2 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 3ef5e74b6..e06b189a0 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -254,9 +254,37 @@ 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(macro_def) = sema.resolve_macro_call(&macro_call) { 280 if let Some(path) = macro_call.path() {
259 return Some(NameRefClass::Definition(Definition::Macro(macro_def))); 281 if path.qualifier().is_none() {
282 // Only use this to resolve single-segment macro calls like `foo!()`. Multi-segment
283 // paths are handled below (allowing `log<|>::info!` to resolve to the log crate).
284 if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
285 return Some(NameRefClass::Definition(Definition::Macro(macro_def)));
286 }
287 }
260 } 288 }
261 } 289 }
262 290