Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir_def/src/type_ref.rs25
-rw-r--r--crates/hir_ty/src/display.rs6
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) = &parameters[index];
+ 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)?,
};