From 3bba811e925e8eb5d53a58b7cb8a10fa29f71caa Mon Sep 17 00:00:00 2001 From: Jeroen Vannevel Date: Tue, 15 Feb 2022 14:47:51 +0000 Subject: [PATCH] fmt --- crates/hir_def/src/type_ref.rs | 25 ++++++++++++++----------- crates/hir_ty/src/display.rs | 6 +++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs index 8667e0a7d6..dcc43c1fad 100644 --- a/crates/hir_def/src/type_ref.rs +++ b/crates/hir_def/src/type_ref.rs @@ -188,11 +188,18 @@ impl TypeRef { is_varargs = param.dotdotdot_token().is_some(); } - pl.params().map(|p| (p.pat(), p.ty())).map(|it| { - let type_ref = TypeRef::from_ast_opt(ctx, it.1); - let name = if it.0.is_some() { Some(it.0.unwrap().syntax().text().to_string()) } else { None }; - (name, type_ref) - }).collect() + pl.params() + .map(|p| (p.pat(), p.ty())) + .map(|it| { + let type_ref = TypeRef::from_ast_opt(ctx, it.1); + let name = if it.0.is_some() { + Some(it.0.unwrap().syntax().text().to_string()) + } else { + None + }; + (name, type_ref) + }) + .collect() } else { Vec::new() }; @@ -234,12 +241,8 @@ impl TypeRef { fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) { f(type_ref); match type_ref { - TypeRef::Fn(types, _) => { - types.iter().for_each(|t| go(&t.1, f)) - } - TypeRef::Tuple(types) => { - types.iter().for_each(|t| go(t, f)) - } + TypeRef::Fn(types, _) => types.iter().for_each(|t| go(&t.1, f)), + TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)), TypeRef::RawPtr(type_ref, _) | TypeRef::Reference(type_ref, ..) | TypeRef::Array(type_ref, _) diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index ad330d6261..4b077c2c8a 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -340,7 +340,7 @@ impl HirDisplay for Ty { if f.should_truncate() { return write!(f, "{}", TYPE_HINT_TRUNCATION); } - + match self.kind(Interner) { TyKind::Never => write!(f, "!")?, TyKind::Str => write!(f, "str")?, @@ -1097,12 +1097,12 @@ impl HirDisplay for TypeRef { TypeRef::Fn(parameters, is_varargs) => { write!(f, "fn(")?; for index in 0..parameters.len() - 1 { - let (param_name,param_type) = ¶meters[index]; + let (param_name, param_type) = ¶meters[index]; match param_name { Some(name) => { write!(f, "{}: ", name)?; param_type.hir_fmt(f)?; - }, + } None => write!(f, " : {:?}", param_type)?, };