about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2022-01-07 03:58:32 +0000
committerkadmin <julianknodt@gmail.com>2022-01-17 17:20:57 +0000
commitcf86d532029bb27ef96780015a50613d2130102b (patch)
tree26875480bd4570d6bd84d2274e5d2b19530bf3f8
parentf5ce84e4f25304dfbf9efeb26a85ef3c9ad594ad (diff)
downloadrust-cf86d532029bb27ef96780015a50613d2130102b.tar.gz
rust-cf86d532029bb27ef96780015a50613d2130102b.zip
Add term
Instead of having a separate enum variant for types and consts have one but have either a const
or type.
-rw-r--r--src/types.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/types.rs b/src/types.rs
index 4bad9742a0e..9d5f790e809 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,7 +1,7 @@
 use std::iter::ExactSizeIterator;
 use std::ops::Deref;
 
-use rustc_ast::ast::{self, FnRetTy, Mutability};
+use rustc_ast::ast::{self, FnRetTy, Mutability, Term};
 use rustc_ast::ptr;
 use rustc_span::{symbol::kw, BytePos, Pos, Span};
 
@@ -178,7 +178,7 @@ impl<'a> Rewrite for SegmentParam<'a> {
 
 impl Rewrite for ast::AssocConstraint {
     fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
-        use ast::AssocConstraintKind::{Bound, Equality, ConstEquality};
+        use ast::AssocConstraintKind::{Bound, Equality};
 
         let mut result = String::with_capacity(128);
         result.push_str(rewrite_ident(context, self.ident));
@@ -192,8 +192,8 @@ impl Rewrite for ast::AssocConstraint {
 
         let infix = match (&self.kind, context.config.type_punctuation_density()) {
             (Bound { .. }, _) => ": ",
-            (ConstEquality { .. } | Equality { .. }, TypeDensity::Wide) => " = ",
-            (ConstEquality { .. } | Equality { .. }, TypeDensity::Compressed) => "=",
+            (Equality { .. }, TypeDensity::Wide) => " = ",
+            (Equality { .. }, TypeDensity::Compressed) => "=",
         };
         result.push_str(infix);
 
@@ -209,8 +209,10 @@ impl Rewrite for ast::AssocConstraint {
 impl Rewrite for ast::AssocConstraintKind {
     fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         match self {
-            ast::AssocConstraintKind::Equality { ty } => ty.rewrite(context, shape),
-            ast::AssocConstraintKind::ConstEquality { c } => c.rewrite(context, shape),
+            ast::AssocConstraintKind::Equality { term } => match term {
+                Term::Ty(ty) => ty.rewrite(context, shape),
+                Term::Const(c) => c.rewrite(context,shape),
+            },
             ast::AssocConstraintKind::Bound { bounds } => bounds.rewrite(context, shape),
         }
     }