]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide_completion/src/completions/attribute/derive.rs
Merge #11393
[rust.git] / crates / ide_completion / src / completions / attribute / derive.rs
index 3cab1918f3ee5b990c855f254f4ad0f576ab74b4..29fe096e135608fd9c6817a000c5cb4aee92d7f3 100644 (file)
     item::CompletionItem, Completions, ImportEdit,
 };
 
-pub(super) fn complete_derive(
-    acc: &mut Completions,
-    ctx: &CompletionContext,
-    existing_derives: &[ast::Path],
-) {
+pub(super) fn complete_derive(acc: &mut Completions, ctx: &CompletionContext, attr: &ast::Attr) {
     let core = ctx.famous_defs().core();
-    let existing_derives: FxHashSet<_> = existing_derives
-        .into_iter()
-        .filter_map(|path| ctx.scope.speculative_resolve_as_mac(&path))
-        .filter(|mac| mac.kind() == MacroKind::Derive)
-        .collect();
+    let existing_derives: FxHashSet<_> =
+        ctx.sema.resolve_derive_macro(attr).into_iter().flatten().flatten().collect();
 
     for (name, mac) in get_derives_in_scope(ctx) {
         if existing_derives.contains(&mac) {
@@ -87,7 +80,7 @@ fn flyimport_derive(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
         return None;
     };
     let potential_import_name = ctx.token.to_string();
-    let module = ctx.scope.module()?;
+    let module = ctx.module?;
     let parent = ctx.token.parent()?;
     let user_input_lowercased = potential_import_name.to_lowercase();
     let import_assets = ImportAssets::for_fuzzy_path(