diff options
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 3b2bfd67a..eb7764f65 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -25,6 +25,7 @@ use std::{fmt, mem}; | |||
25 | use log; | 25 | use log; |
26 | use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; | 26 | use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; |
27 | use ra_arena::map::ArenaMap; | 27 | use ra_arena::map::ArenaMap; |
28 | use join_to_string::join; | ||
28 | 29 | ||
29 | use ra_db::Cancelable; | 30 | use ra_db::Cancelable; |
30 | 31 | ||
@@ -396,18 +397,21 @@ impl fmt::Display for Ty { | |||
396 | Ty::Ref(t, m) => write!(f, "&{}{}", m.as_keyword_for_ref(), t), | 397 | Ty::Ref(t, m) => write!(f, "&{}{}", m.as_keyword_for_ref(), t), |
397 | Ty::Never => write!(f, "!"), | 398 | Ty::Never => write!(f, "!"), |
398 | Ty::Tuple(ts) => { | 399 | Ty::Tuple(ts) => { |
399 | write!(f, "(")?; | 400 | if ts.len() == 1 { |
400 | for t in ts.iter() { | 401 | write!(f, "({},)", ts[0]) |
401 | write!(f, "{},", t)?; | 402 | } else { |
403 | join(ts.iter()) | ||
404 | .surround_with("(", ")") | ||
405 | .separator(", ") | ||
406 | .to_fmt(f) | ||
402 | } | 407 | } |
403 | write!(f, ")") | ||
404 | } | 408 | } |
405 | Ty::FnPtr(sig) => { | 409 | Ty::FnPtr(sig) => { |
406 | write!(f, "fn(")?; | 410 | join(sig.input.iter()) |
407 | for t in &sig.input { | 411 | .surround_with("fn(", ")") |
408 | write!(f, "{},", t)?; | 412 | .separator(", ") |
409 | } | 413 | .to_fmt(f)?; |
410 | write!(f, ") -> {}", sig.output) | 414 | write!(f, " -> {}", sig.output) |
411 | } | 415 | } |
412 | Ty::Adt { name, .. } => write!(f, "{}", name), | 416 | Ty::Adt { name, .. } => write!(f, "{}", name), |
413 | Ty::Unknown => write!(f, "[unknown]"), | 417 | Ty::Unknown => write!(f, "[unknown]"), |