fix: handling of associated type bounds

This commit is contained in:
calebcartwright 2019-06-28 16:15:42 -05:00
parent e0e2f0db53
commit 731f7d5200

View file

@ -168,14 +168,22 @@ impl<'a> Rewrite for SegmentParam<'a> {
SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
SegmentParam::Type(ty) => ty.rewrite(context, shape),
SegmentParam::Binding(assoc_ty_constraint) => {
let mut result = match context.config.type_punctuation_density() {
TypeDensity::Wide => {
format!("{} = ", rewrite_ident(context, assoc_ty_constraint.ident))
let mut result = match assoc_ty_constraint.kind {
ast::AssocTyConstraintKind::Bound { .. } => {
format!("{}: ", rewrite_ident(context, assoc_ty_constraint.ident))
}
TypeDensity::Compressed => {
format!("{}=", rewrite_ident(context, assoc_ty_constraint.ident))
ast::AssocTyConstraintKind::Equality { .. } => {
match context.config.type_punctuation_density() {
TypeDensity::Wide => {
format!("{} = ", rewrite_ident(context, assoc_ty_constraint.ident))
}
TypeDensity::Compressed => {
format!("{}=", rewrite_ident(context, assoc_ty_constraint.ident))
}
}
}
};
let budget = shape.width.checked_sub(result.len())?;
let rewrite = assoc_ty_constraint
.kind