From 54cc3fee4550ec7e2e8b6f118de4b7ced546bc97 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 20 Jul 2020 23:50:41 +0300 Subject: Do not show default types in closures --- crates/ra_hir_ty/src/display.rs | 22 +++++++++++++++++++--- crates/ra_ide/src/inlay_hints.rs | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 758d5f5ac..19770e609 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs @@ -257,7 +257,12 @@ impl HirDisplay for ApplicationTy { write!(f, ")")?; let ret = sig.ret(); if *ret != Ty::unit() { - write!(f, " -> {}", ret.display(f.db))?; + let ret_display = if f.omit_verbose_types() { + ret.display_truncated(f.db, f.max_size) + } else { + ret.display(f.db) + }; + write!(f, " -> {}", ret_display)?; } } TypeCtor::FnDef(def) => { @@ -288,7 +293,12 @@ impl HirDisplay for ApplicationTy { write!(f, ")")?; let ret = sig.ret(); if *ret != Ty::unit() { - write!(f, " -> {}", ret.display(f.db))?; + let ret_display = if f.omit_verbose_types() { + ret.display_truncated(f.db, f.max_size) + } else { + ret.display(f.db) + }; + write!(f, " -> {}", ret_display)?; } } TypeCtor::Adt(def_id) => { @@ -397,7 +407,13 @@ impl HirDisplay for ApplicationTy { f.write_joined(sig.params(), ", ")?; write!(f, "|")?; }; - write!(f, " -> {}", sig.ret().display(f.db))?; + + let ret_display = if f.omit_verbose_types() { + sig.ret().display_truncated(f.db, f.max_size) + } else { + sig.ret().display(f.db) + }; + write!(f, " -> {}", ret_display)?; } else { write!(f, "{{closure}}")?; } diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 09883ab4d..f2e4f7ee5 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -425,6 +425,8 @@ fn main() { //^^ Test let zz_ref = &zz; //^^^^^^ &Test + let test = || zz; + //^^^^ || -> Test }"#, ); } -- cgit v1.2.3