Skip to content

Commit cf86d53

Browse files
committed
Add term
Instead of having a separate enum variant for types and consts have one but have either a const or type.
1 parent f5ce84e commit cf86d53

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/types.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::iter::ExactSizeIterator;
22
use std::ops::Deref;
33

4-
use rustc_ast::ast::{self, FnRetTy, Mutability};
4+
use rustc_ast::ast::{self, FnRetTy, Mutability, Term};
55
use rustc_ast::ptr;
66
use rustc_span::{symbol::kw, BytePos, Pos, Span};
77

@@ -178,7 +178,7 @@ impl<'a> Rewrite for SegmentParam<'a> {
178178

179179
impl Rewrite for ast::AssocConstraint {
180180
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
181-
use ast::AssocConstraintKind::{Bound, Equality, ConstEquality};
181+
use ast::AssocConstraintKind::{Bound, Equality};
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::AssocConstraint {
192192

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

@@ -209,8 +209,10 @@ impl Rewrite for ast::AssocConstraint {
209209
impl Rewrite for ast::AssocConstraintKind {
210210
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
211211
match self {
212-
ast::AssocConstraintKind::Equality { ty } => ty.rewrite(context, shape),
213-
ast::AssocConstraintKind::ConstEquality { c } => c.rewrite(context, shape),
212+
ast::AssocConstraintKind::Equality { term } => match term {
213+
Term::Ty(ty) => ty.rewrite(context, shape),
214+
Term::Const(c) => c.rewrite(context,shape),
215+
},
214216
ast::AssocConstraintKind::Bound { bounds } => bounds.rewrite(context, shape),
215217
}
216218
}

0 commit comments

Comments
 (0)