iter 22-tidy.6.2: write_fn_def renders forall class constraints
This commit is contained in:
@@ -238,9 +238,11 @@ fn write_fn_def(out: &mut String, fd: &FnDef, level: usize) {
|
||||
// `Type::Fn` or a `Type::Forall` wrapping one — in the latter case
|
||||
// we render the forall on the line above and then the inner fn
|
||||
// signature.
|
||||
let (forall_vars, fn_ty) = match &fd.ty {
|
||||
Type::Forall { vars, constraints: _, body } => (Some(vars.clone()), body.as_ref()),
|
||||
other => (None, other),
|
||||
let (forall_vars, forall_constraints, fn_ty) = match &fd.ty {
|
||||
Type::Forall { vars, constraints, body } => {
|
||||
(Some(vars.clone()), constraints.clone(), body.as_ref())
|
||||
}
|
||||
other => (None, Vec::new(), other),
|
||||
};
|
||||
|
||||
if let Some(vars) = &forall_vars {
|
||||
@@ -252,7 +254,19 @@ fn write_fn_def(out: &mut String, fd: &FnDef, level: usize) {
|
||||
}
|
||||
out.push_str(v);
|
||||
}
|
||||
out.push_str(">\n");
|
||||
out.push('>');
|
||||
if !forall_constraints.is_empty() {
|
||||
out.push_str(" where ");
|
||||
for (i, c) in forall_constraints.iter().enumerate() {
|
||||
if i > 0 {
|
||||
out.push_str(", ");
|
||||
}
|
||||
out.push_str(&c.class);
|
||||
out.push(' ');
|
||||
write_type(out, &c.type_);
|
||||
}
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
|
||||
indent(out, level);
|
||||
|
||||
Reference in New Issue
Block a user