Skip to content

Commit f5ce84e

Browse files
committed
add eq constraints on associated constants
1 parent 8ae2312 commit f5ce84e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/types.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub(crate) enum SegmentParam<'a> {
141141
Const(&'a ast::AnonConst),
142142
LifeTime(&'a ast::Lifetime),
143143
Type(&'a ast::Ty),
144-
Binding(&'a ast::AssocTyConstraint),
144+
Binding(&'a ast::AssocConstraint),
145145
}
146146

147147
impl<'a> SegmentParam<'a> {
@@ -176,9 +176,9 @@ impl<'a> Rewrite for SegmentParam<'a> {
176176
}
177177
}
178178

179-
impl Rewrite for ast::AssocTyConstraint {
179+
impl Rewrite for ast::AssocConstraint {
180180
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
181-
use ast::AssocTyConstraintKind::{Bound, Equality};
181+
use ast::AssocConstraintKind::{Bound, Equality, ConstEquality};
182182

183183
let mut result = String::with_capacity(128);
184184
result.push_str(rewrite_ident(context, self.ident));
@@ -192,8 +192,8 @@ impl Rewrite for ast::AssocTyConstraint {
192192

193193
let infix = match (&self.kind, context.config.type_punctuation_density()) {
194194
(Bound { .. }, _) => ": ",
195-
(Equality { .. }, TypeDensity::Wide) => " = ",
196-
(Equality { .. }, TypeDensity::Compressed) => "=",
195+
(ConstEquality { .. } | Equality { .. }, TypeDensity::Wide) => " = ",
196+
(ConstEquality { .. } | Equality { .. }, TypeDensity::Compressed) => "=",
197197
};
198198
result.push_str(infix);
199199

@@ -206,11 +206,12 @@ impl Rewrite for ast::AssocTyConstraint {
206206
}
207207
}
208208

209-
impl Rewrite for ast::AssocTyConstraintKind {
209+
impl Rewrite for ast::AssocConstraintKind {
210210
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
211211
match self {
212-
ast::AssocTyConstraintKind::Equality { ty } => ty.rewrite(context, shape),
213-
ast::AssocTyConstraintKind::Bound { bounds } => bounds.rewrite(context, shape),
212+
ast::AssocConstraintKind::Equality { ty } => ty.rewrite(context, shape),
213+
ast::AssocConstraintKind::ConstEquality { c } => c.rewrite(context, shape),
214+
ast::AssocConstraintKind::Bound { bounds } => bounds.rewrite(context, shape),
214215
}
215216
}
216217
}

0 commit comments

Comments
 (0)