mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
fmt
This commit is contained in:
parent
c450d0ce41
commit
3bba811e92
2 changed files with 17 additions and 14 deletions
|
@ -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, _)
|
||||
|
|
|
@ -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)?,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue