Skip to content

Commit b4ed3e1

Browse files
Merge #8052
8052: minor style fixes per feedback on #8036 r=JoshMcguigan a=JoshMcguigan cc @matklad - this PR addresses your comments in #8036. changelog fixup #8036 Co-authored-by: Josh Mcguigan <[email protected]>
2 parents da5328a + 81f51fc commit b4ed3e1

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

crates/ide_completion/src/render.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,13 @@ impl<'a> Render<'a> {
307307
}
308308

309309
fn compute_exact_type_match(ctx: &CompletionContext, completion_ty: &hir::Type) -> bool {
310-
if let Some(expected_type) = ctx.expected_type.as_ref() {
311-
// We don't ever consider unit type to be an exact type match, since
312-
// nearly always this is not meaningful to the user.
313-
completion_ty == expected_type && !expected_type.is_unit()
314-
} else {
315-
false
310+
match ctx.expected_type.as_ref() {
311+
Some(expected_type) => {
312+
// We don't ever consider unit type to be an exact type match, since
313+
// nearly always this is not meaningful to the user.
314+
completion_ty == expected_type && !expected_type.is_unit()
315+
}
316+
None => false,
316317
}
317318
}
318319

@@ -323,27 +324,20 @@ fn compute_exact_name_match(ctx: &CompletionContext, completion_name: impl Into<
323324
}
324325

325326
fn compute_ref_match(ctx: &CompletionContext, completion_ty: &hir::Type) -> Option<Mutability> {
326-
let mut ref_match = None;
327-
if let Some(expected_type) = &ctx.expected_type {
328-
if completion_ty != expected_type {
329-
if let Some(expected_type_without_ref) = expected_type.remove_ref() {
330-
if completion_ty == &expected_type_without_ref
331-
|| completion_ty
332-
.autoderef(ctx.db)
333-
.any(|deref_ty| deref_ty == expected_type_without_ref)
334-
{
335-
cov_mark::hit!(suggest_ref);
336-
let mutability = if expected_type.is_mutable_reference() {
337-
Mutability::Mut
338-
} else {
339-
Mutability::Shared
340-
};
341-
ref_match = Some(mutability);
342-
}
343-
}
344-
}
345-
};
346-
ref_match
327+
let expected_type = ctx.expected_type.as_ref()?;
328+
if completion_ty != expected_type {
329+
let expected_type_without_ref = expected_type.remove_ref()?;
330+
if completion_ty.autoderef(ctx.db).any(|deref_ty| deref_ty == expected_type_without_ref) {
331+
cov_mark::hit!(suggest_ref);
332+
let mutability = if expected_type.is_mutable_reference() {
333+
Mutability::Mut
334+
} else {
335+
Mutability::Shared
336+
};
337+
return Some(mutability);
338+
};
339+
}
340+
None
347341
}
348342

349343
#[cfg(test)]

0 commit comments

Comments
 (0)