From 3cadba4956bf22759803024b69b6bb67e34da576 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 3 Oct 2020 13:44:43 +0300 Subject: Improve readability in inlay_hints.rs --- crates/ide/src/inlay_hints.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 29f3b6828..1d7e8de56 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -254,10 +254,11 @@ fn should_not_display_type_hint( ast::ForExpr(it) => { // We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit). // Type of expr should be iterable. - let type_is_known = |ty: Option| ty.map(|ty| !ty.is_unit() && !ty.is_unknown()).unwrap_or(false); - let should_display = it.in_token().is_some() - && it.iterable().map(|expr| type_is_known(sema.type_of_expr(&expr))).unwrap_or(false); - return !should_display; + return it.in_token().is_none() || + it.iterable() + .and_then(|iterable_expr|sema.type_of_expr(&iterable_expr)) + .map(|iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit()) + .unwrap_or(true) }, _ => (), } -- cgit v1.2.3