diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/inlay_hints.rs | 9 |
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 | } |