Skip to content

Commit 54cc3fe

Browse files
Do not show default types in closures
1 parent 76c1fac commit 54cc3fe

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

crates/ra_hir_ty/src/display.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ impl HirDisplay for ApplicationTy {
257257
write!(f, ")")?;
258258
let ret = sig.ret();
259259
if *ret != Ty::unit() {
260-
write!(f, " -> {}", ret.display(f.db))?;
260+
let ret_display = if f.omit_verbose_types() {
261+
ret.display_truncated(f.db, f.max_size)
262+
} else {
263+
ret.display(f.db)
264+
};
265+
write!(f, " -> {}", ret_display)?;
261266
}
262267
}
263268
TypeCtor::FnDef(def) => {
@@ -288,7 +293,12 @@ impl HirDisplay for ApplicationTy {
288293
write!(f, ")")?;
289294
let ret = sig.ret();
290295
if *ret != Ty::unit() {
291-
write!(f, " -> {}", ret.display(f.db))?;
296+
let ret_display = if f.omit_verbose_types() {
297+
ret.display_truncated(f.db, f.max_size)
298+
} else {
299+
ret.display(f.db)
300+
};
301+
write!(f, " -> {}", ret_display)?;
292302
}
293303
}
294304
TypeCtor::Adt(def_id) => {
@@ -397,7 +407,13 @@ impl HirDisplay for ApplicationTy {
397407
f.write_joined(sig.params(), ", ")?;
398408
write!(f, "|")?;
399409
};
400-
write!(f, " -> {}", sig.ret().display(f.db))?;
410+
411+
let ret_display = if f.omit_verbose_types() {
412+
sig.ret().display_truncated(f.db, f.max_size)
413+
} else {
414+
sig.ret().display(f.db)
415+
};
416+
write!(f, " -> {}", ret_display)?;
401417
} else {
402418
write!(f, "{{closure}}")?;
403419
}

crates/ra_ide/src/inlay_hints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ fn main() {
425425
//^^ Test<i32>
426426
let zz_ref = &zz;
427427
//^^^^^^ &Test<i32>
428+
let test = || zz;
429+
//^^^^ || -> Test<i32>
428430
}"#,
429431
);
430432
}

0 commit comments

Comments
 (0)