Skip to content

Commit 51709c5

Browse files
committed
Avoid suggesting redundant borrowing in completion results
1 parent 9df88ff commit 51709c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/ide-completion/src/render.rs

+5
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ fn compute_ref_match(
634634
}
635635

636636
if let Some(expected_without_ref) = &expected_without_ref {
637+
if completion_ty == &expected_without_ref.add_reference(hir::Mutability::Shared)
638+
|| completion_ty == &expected_without_ref.add_reference(hir::Mutability::Mut)
639+
{
640+
return None;
641+
}
637642
if completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref) {
638643
cov_mark::hit!(suggest_ref);
639644
let mutability = if expected_type.is_mutable_reference() {

0 commit comments

Comments
 (0)