This commit is contained in:
Jeroen Vannevel 2022-02-15 14:47:51 +00:00
parent c450d0ce41
commit 3bba811e92
No known key found for this signature in database
GPG key ID: 78EF5F52F38C49BD
2 changed files with 17 additions and 14 deletions

View file

@ -188,11 +188,18 @@ impl TypeRef {
is_varargs = param.dotdotdot_token().is_some();
}
pl.params().map(|p| (p.pat(), p.ty())).map(|it| {
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 };
let name = if it.0.is_some() {
Some(it.0.unwrap().syntax().text().to_string())
} else {
None
};
(name, type_ref)
}).collect()
})
.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, _)

View file

@ -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)?,
};