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 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ide-completion/src/completions/attribute/derive.rs b/crates/ide-completion/src/completions/attribute/derive.rs index 0d4a292e0f..3aaaecd474 100644 --- a/crates/ide-completion/src/completions/attribute/derive.rs +++ b/crates/ide-completion/src/completions/attribute/derive.rs @@ -11,8 +11,10 @@ use crate::{ }; pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) { - let qualified = match ctx.path_context() { - Some(&PathCompletionCtx { kind: PathKind::Derive, ref qualified, .. }) => qualified, + let (qualified, existing_derives) = match ctx.path_context() { + Some(PathCompletionCtx { + kind: PathKind::Derive { existing_derives }, qualified, .. + }) => (qualified, existing_derives), _ => return, }; @@ -32,7 +34,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) { for (name, def) in module.scope(ctx.db, Some(ctx.module)) { let add_def = match def { ScopeDef::ModuleDef(hir::ModuleDef::Macro(mac)) => { - !ctx.existing_derives.contains(&mac) && mac.is_derive(ctx.db) + !existing_derives.contains(&mac) && mac.is_derive(ctx.db) } ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) => true, _ => false, @@ -48,7 +50,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) { ctx.process_all_names(&mut |name, def| { let mac = match def { ScopeDef::ModuleDef(hir::ModuleDef::Macro(mac)) - if !ctx.existing_derives.contains(&mac) && mac.is_derive(ctx.db) => + if !existing_derives.contains(&mac) && mac.is_derive(ctx.db) => { mac } @@ -74,7 +76,7 @@ pub(crate) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext) { let mut components = vec![derive_completion.label]; components.extend(derive_completion.dependencies.iter().filter( |&&dependency| { - !ctx.existing_derives + !existing_derives .iter() .map(|it| it.name(ctx.db)) .any(|it| it.to_smol_str() == dependency) |