Skip to content

Commit 3cadba4

Browse files
committed
Improve readability in inlay_hints.rs
1 parent 91a09f5 commit 3cadba4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/ide/src/inlay_hints.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,11 @@ fn should_not_display_type_hint(
254254
ast::ForExpr(it) => {
255255
// We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit).
256256
// Type of expr should be iterable.
257-
let type_is_known = |ty: Option<hir::Type>| ty.map(|ty| !ty.is_unit() && !ty.is_unknown()).unwrap_or(false);
258-
let should_display = it.in_token().is_some()
259-
&& it.iterable().map(|expr| type_is_known(sema.type_of_expr(&expr))).unwrap_or(false);
260-
return !should_display;
257+
return it.in_token().is_none() ||
258+
it.iterable()
259+
.and_then(|iterable_expr|sema.type_of_expr(&iterable_expr))
260+
.map(|iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit())
261+
.unwrap_or(true)
261262
},
262263
_ => (),
263264
}

0 commit comments

Comments
 (0)