Skip to content

Commit f6b0c19

Browse files
committed
dedupe by name
1 parent 50b427c commit f6b0c19

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/ide-assists/src/handlers/generate_delegate_methods.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashSet;
2+
13
use hir::{self, HasCrate, HasSource, HasVisibility};
24
use syntax::ast::{self, make, AstNode, HasGenericParams, HasName, HasVisibility as _};
35

@@ -64,12 +66,16 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'
6466

6567
let sema_field_ty = ctx.sema.resolve_type(&field_ty)?;
6668
let mut methods = vec![];
69+
let mut seen_names = HashSet::new();
6770

6871
for ty in sema_field_ty.autoderef(ctx.db()) {
6972
let krate = ty.krate(ctx.db());
7073
ty.iterate_assoc_items(ctx.db(), krate, |item| {
7174
if let hir::AssocItem::Function(f) = item {
72-
if f.self_param(ctx.db()).is_some() && f.is_visible_from(ctx.db(), current_module) {
75+
if f.self_param(ctx.db()).is_some()
76+
&& f.is_visible_from(ctx.db(), current_module)
77+
&& seen_names.insert(f.name(ctx.db()))
78+
{
7379
methods.push(f)
7480
}
7581
}

0 commit comments

Comments
 (0)