diff options
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/display.rs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 14e8c0633..e77481906 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -297,26 +297,7 @@ impl HirDisplay for ApplicationTy { | |||
297 | } | 297 | } |
298 | TypeCtor::FnPtr { is_varargs, .. } => { | 298 | TypeCtor::FnPtr { is_varargs, .. } => { |
299 | let sig = FnSig::from_fn_ptr_substs(&self.parameters, is_varargs); | 299 | let sig = FnSig::from_fn_ptr_substs(&self.parameters, is_varargs); |
300 | write!(f, "fn(")?; | 300 | sig.hir_fmt(f)?; |
301 | f.write_joined(sig.params(), ", ")?; | ||
302 | if is_varargs { | ||
303 | if sig.params().is_empty() { | ||
304 | write!(f, "...")?; | ||
305 | } else { | ||
306 | write!(f, ", ...")?; | ||
307 | } | ||
308 | } | ||
309 | write!(f, ")")?; | ||
310 | let ret = sig.ret(); | ||
311 | if *ret != Ty::unit() { | ||
312 | let ret_display = ret.into_displayable( | ||
313 | f.db, | ||
314 | f.max_size, | ||
315 | f.omit_verbose_types, | ||
316 | f.display_target, | ||
317 | ); | ||
318 | write!(f, " -> {}", ret_display)?; | ||
319 | } | ||
320 | } | 301 | } |
321 | TypeCtor::FnDef(def) => { | 302 | TypeCtor::FnDef(def) => { |
322 | let sig = f.db.callable_item_signature(def).subst(&self.parameters); | 303 | let sig = f.db.callable_item_signature(def).subst(&self.parameters); |
@@ -584,6 +565,28 @@ impl HirDisplay for Ty { | |||
584 | } | 565 | } |
585 | } | 566 | } |
586 | 567 | ||
568 | impl HirDisplay for FnSig { | ||
569 | fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { | ||
570 | write!(f, "fn(")?; | ||
571 | f.write_joined(self.params(), ", ")?; | ||
572 | if self.is_varargs { | ||
573 | if self.params().is_empty() { | ||
574 | write!(f, "...")?; | ||
575 | } else { | ||
576 | write!(f, ", ...")?; | ||
577 | } | ||
578 | } | ||
579 | write!(f, ")")?; | ||
580 | let ret = self.ret(); | ||
581 | if *ret != Ty::unit() { | ||
582 | let ret_display = | ||
583 | ret.into_displayable(f.db, f.max_size, f.omit_verbose_types, f.display_target); | ||
584 | write!(f, " -> {}", ret_display)?; | ||
585 | } | ||
586 | Ok(()) | ||
587 | } | ||
588 | } | ||
589 | |||
587 | fn write_bounds_like_dyn_trait( | 590 | fn write_bounds_like_dyn_trait( |
588 | predicates: &[GenericPredicate], | 591 | predicates: &[GenericPredicate], |
589 | f: &mut HirFormatter, | 592 | f: &mut HirFormatter, |