]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/interner.rs
Add lowering of array lengths in types
[rust.git] / crates / hir_ty / src / interner.rs
index a1656115d65dd424eba927b32766db96190b1af4..7b41197477a75d2fa6cd1170a2ddec9e7a875d02 100644 (file)
@@ -6,6 +6,7 @@
 use chalk_ir::{Goal, GoalData};
 use hir_def::{
     intern::{impl_internable, InternStorage, Internable, Interned},
+    type_ref::ConstScalar,
     TypeAliasId,
 };
 use smallvec::SmallVec;
@@ -31,6 +32,7 @@ fn deref(&self) -> &Self::Target {
     InternedWrapper<chalk_ir::TyData<Interner>>,
     InternedWrapper<chalk_ir::LifetimeData<Interner>>,
     InternedWrapper<chalk_ir::ConstData<Interner>>,
+    InternedWrapper<ConstScalar>,
     InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
     InternedWrapper<Vec<chalk_ir::ProgramClause<Interner>>>,
     InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Interner>>>,
@@ -41,7 +43,7 @@ impl chalk_ir::interner::Interner for Interner {
     type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Interner>>>;
     type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
     type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
-    type InternedConcreteConst = ();
+    type InternedConcreteConst = ConstScalar;
     type InternedGenericArg = chalk_ir::GenericArgData<Self>;
     type InternedGoal = Arc<GoalData<Self>>;
     type InternedGoals = Vec<Goal<Self>>;
@@ -245,10 +247,15 @@ fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::Con
     fn const_eq(
         &self,
         _ty: &Self::InternedType,
-        _c1: &Self::InternedConcreteConst,
-        _c2: &Self::InternedConcreteConst,
+        c1: &Self::InternedConcreteConst,
+        c2: &Self::InternedConcreteConst,
     ) -> bool {
-        true
+        match (c1, c2) {
+            (&ConstScalar::Usize(a), &ConstScalar::Usize(b)) => a == b,
+            // we were previously assuming this to be true, I'm not whether true or false on
+            // unknown values is safer.
+            (_, _) => true,
+        }
     }
 
     fn intern_generic_arg(