]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/display.rs
re-added FIXME
[rust.git] / crates / hir_ty / src / display.rs
index bca628a5c8864d6fb3f1bce939fe6504db0201ee..2ee4f5cf41bf351508ab8bf3143c1bd1f4bde481 100644 (file)
@@ -239,7 +239,6 @@ impl<'a, T> fmt::Display for HirDisplayWrapper<'a, T>
     T: HirDisplay,
 {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        println!("formatting..");
         match self.t.hir_fmt(&mut HirFormatter {
             db: self.db,
             fmt: f,
@@ -342,9 +341,6 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
             return write!(f, "{}", TYPE_HINT_TRUNCATION);
         }
 
-        let interner_kind = self.kind(Interner);
-        println!("interner kind: {interner_kind:?}");
-
         match self.kind(Interner) {
             TyKind::Never => write!(f, "!")?,
             TyKind::Str => write!(f, "str")?,
@@ -1099,17 +1095,17 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
                 write!(f, "]")?;
             }
             TypeRef::Fn(parameters, is_varargs) => {
+                // FIXME: Function pointer qualifiers.
                 write!(f, "fn(")?;
                 for index in 0..parameters.len() - 1 {
-                    let (param_name,param_type) = &parameters[index];
-                    match param_name {
-                        Some(name) => {
-                            write!(f, "{}: ", name)?;
-                            param_type.hir_fmt(f)?;
-                        },
-                        None => write!(f, " : {:?}", param_type)?,
-                    };
+                    let (param_name, param_type) = &parameters[index];
+                    if let Some(name) = param_name {
+                        write!(f, "{}: ", name)?;
+                    }
 
+                    param_type.hir_fmt(f)?;
+
+                    // Last index contains the return type so we stop writing commas on the second-to-last index
                     if index != parameters.len() - 2 {
                         write!(f, ", ")?;
                     }
@@ -1118,12 +1114,13 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
                     write!(f, "{}...", if parameters.len() == 1 { "" } else { ", " })?;
                 }
                 write!(f, ")")?;
-                let ret_ty = &parameters.last().unwrap().1;
-                match ret_ty {
-                    TypeRef::Tuple(tup) if tup.is_empty() => {}
-                    _ => {
-                        write!(f, " -> ")?;
-                        ret_ty.hir_fmt(f)?;
+                if let Some((_, ret_ty)) = &parameters.last() {
+                    match ret_ty {
+                        TypeRef::Tuple(tup) if tup.is_empty() => {}
+                        _ => {
+                            write!(f, " -> ")?;
+                            ret_ty.hir_fmt(f)?;
+                        }
                     }
                 }
             }