1
Fork 0

Avoid suggesting redundant borrowing in completion results

This commit is contained in:
bit-aloo 2025-02-26 20:24:37 +05:30
parent da06b7c1bb
commit 73488449c5
No known key found for this signature in database
GPG key ID: 02911B24FDAE81DA

View file

@ -628,11 +628,9 @@ fn compute_ref_match(
let expected_type = ctx.expected_type.as_ref()?;
let expected_without_ref = expected_type.remove_ref();
let completion_without_ref = completion_ty.remove_ref();
if completion_ty == expected_type {
if expected_type.could_unify_with(ctx.db, completion_ty) {
return None;
}
if let Some(expected_without_ref) = &expected_without_ref {
if completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref) {
cov_mark::hit!(suggest_ref);