Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/attribute/derive.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/attribute/derive.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/crates/ide-completion/src/completions/attribute/derive.rs b/crates/ide-completion/src/completions/attribute/derive.rs index 5dee4d7956..0e10f38153 100644 --- a/crates/ide-completion/src/completions/attribute/derive.rs +++ b/crates/ide-completion/src/completions/attribute/derive.rs @@ -10,7 +10,7 @@ use crate::{ Completions, }; -pub(crate) fn complete_derive( +pub(crate) fn complete_derive_path( acc: &mut Completions, ctx: &CompletionContext, PathCompletionCtx { qualified, .. }: &PathCompletionCtx, @@ -29,15 +29,14 @@ pub(crate) fn complete_derive( } for (name, def) in module.scope(ctx.db, Some(ctx.module)) { - let add_def = match def { - ScopeDef::ModuleDef(hir::ModuleDef::Macro(mac)) => { - !existing_derives.contains(&mac) && mac.is_derive(ctx.db) + match def { + ScopeDef::ModuleDef(hir::ModuleDef::Macro(mac)) + if !existing_derives.contains(&mac) && mac.is_derive(ctx.db) => + { + acc.add_macro(ctx, mac, name) } - ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) => true, - _ => false, - }; - if add_def { - acc.add_resolution(ctx, name, def); + ScopeDef::ModuleDef(hir::ModuleDef::Module(m)) => acc.add_module(ctx, m, name), + _ => (), } } } @@ -51,8 +50,8 @@ pub(crate) fn complete_derive( { mac } - ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) => { - return acc.add_resolution(ctx, name, def); + ScopeDef::ModuleDef(hir::ModuleDef::Module(m)) => { + return acc.add_module(ctx, m, name); } _ => return, }; @@ -60,7 +59,7 @@ pub(crate) fn complete_derive( match (core, mac.module(ctx.db).krate()) { // show derive dependencies for `core`/`std` derives (Some(core), mac_krate) if core == mac_krate => {} - _ => return acc.add_resolution(ctx, name, def), + _ => return acc.add_macro(ctx, mac, name), }; let name_ = name.to_smol_str(); @@ -93,7 +92,7 @@ pub(crate) fn complete_derive( item.lookup_by(lookup); item.add_to(acc); } - None => acc.add_resolution(ctx, name, def), + None => acc.add_macro(ctx, mac, name), } }); acc.add_nameref_keywords_with_colon(ctx); |