aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-10-03 11:44:43 +0100
committerIgor Aleksanov <[email protected]>2020-10-03 11:44:43 +0100
commit3cadba4956bf22759803024b69b6bb67e34da576 (patch)
treea9d154c1920dd03e72d83f016e77eb8b652fbbc4
parent91a09f50f47d451d40fe863ec4af7e2b38ed5a45 (diff)
Improve readability in inlay_hints.rs
-rw-r--r--crates/ide/src/inlay_hints.rs9
1 files changed, 5 insertions, 4 deletions
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(
254 ast::ForExpr(it) => { 254 ast::ForExpr(it) => {
255 // We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit). 255 // We *should* display hint only if user provided "in {expr}" and we know the type of expr (and it's not unit).
256 // Type of expr should be iterable. 256 // 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); 257 return it.in_token().is_none() ||
258 let should_display = it.in_token().is_some() 258 it.iterable()
259 && it.iterable().map(|expr| type_is_known(sema.type_of_expr(&expr))).unwrap_or(false); 259 .and_then(|iterable_expr|sema.type_of_expr(&iterable_expr))
260 return !should_display; 260 .map(|iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit())
261 .unwrap_or(true)
261 }, 262 },
262 _ => (), 263 _ => (),
263 } 264 }