@@ -26,7 +26,7 @@ type TraitKinds = BTreeMap<chalk_ir::TraitId<ChalkIr>, TypeKind>;
2626type AssociatedTyLookups = BTreeMap<(chalk_ir::TraitId<ChalkIr>, Ident), AssociatedTyLookup>;
2727type AssociatedTyValueIds =
2828 BTreeMap<(chalk_ir::ImplId<ChalkIr>, Ident), AssociatedTyValueId<ChalkIr>>;
29- type ParameterMap = BTreeMap<Ident, chalk_ir::ParameterKind<BoundVar>>;
29+ type ParameterMap = BTreeMap<Ident, chalk_ir::ParameterKind<ChalkIr, BoundVar>>;
3030
3131pub type LowerResult<T> = Result<T, RustIrError>;
3232
@@ -65,7 +65,7 @@ impl<'k> Env<'k> {
6565#[derive(Debug, PartialEq, Eq)]
6666struct AssociatedTyLookup {
6767 id: chalk_ir::AssocTypeId<ChalkIr>,
68- addl_parameter_kinds: Vec<chalk_ir::ParameterKind<()>>,
68+ addl_parameter_kinds: Vec<chalk_ir::ParameterKind<ChalkIr, ()>>,
6969}
7070
7171enum ApplyTypeLookup {
@@ -80,16 +80,16 @@ impl<'k> Env<'k> {
8080 let interner = self.interner();
8181
8282 if let Some(p) = self.parameter_map.get(&name.str) {
83- return match * p {
84- chalk_ir::ParameterKind::Ty(b) => Ok(chalk_ir::TyData::BoundVar(b)
83+ return match p {
84+ chalk_ir::ParameterKind::Ty(b) => Ok(chalk_ir::TyData::BoundVar(* b)
8585 .intern(interner)
8686 .cast(interner)),
87- chalk_ir::ParameterKind::Lifetime(b) => Ok(chalk_ir::LifetimeData::BoundVar(b)
88- .intern(interner)
89- .cast(interner)),
90- chalk_ir::ParameterKind::Const(b) => Ok(chalk_ir::ConstData::BoundVar(b)
87+ chalk_ir::ParameterKind::Lifetime(b) => Ok(chalk_ir::LifetimeData::BoundVar(*b)
9188 .intern(interner)
9289 .cast(interner)),
90+ chalk_ir::ParameterKind::Const { ty, value: b } => {
91+ Ok(b.to_const(interner, ty.clone()).cast(interner))
92+ }
9393 };
9494 }
9595
@@ -173,7 +173,7 @@ impl<'k> Env<'k> {
173173 /// will be assigned in order as they are iterated.
174174 fn introduce<I>(&self, binders: I) -> LowerResult<Self>
175175 where
176- I: IntoIterator<Item = chalk_ir::ParameterKind<Ident>>,
176+ I: IntoIterator<Item = chalk_ir::ParameterKind<ChalkIr, Ident>>,
177177 I::IntoIter: ExactSizeIterator,
178178 {
179179 // As binders to introduce we recieve `ParameterKind<Ident>`,
@@ -192,7 +192,7 @@ impl<'k> Env<'k> {
192192 let parameter_map: ParameterMap = self
193193 .parameter_map
194194 .iter()
195- .map(|(& k, & v)| (k, v.map (|b| b.shifted_in())))
195+ .map(|(k, v)| (* k, v.map_ref (|b| b.shifted_in())))
196196 .chain(binders)
197197 .collect();
198198 if parameter_map.len() != self.parameter_map.len() + len {
@@ -206,7 +206,7 @@ impl<'k> Env<'k> {
206206
207207 fn in_binders<I, T, OP>(&self, binders: I, op: OP) -> LowerResult<chalk_ir::Binders<T>>
208208 where
209- I: IntoIterator<Item = chalk_ir::ParameterKind<Ident>>,
209+ I: IntoIterator<Item = chalk_ir::ParameterKind<ChalkIr, Ident>>,
210210 I::IntoIter: ExactSizeIterator,
211211 T: HasInterner<Interner = ChalkIr>,
212212 OP: FnOnce(&Self) -> LowerResult<T>,
@@ -499,9 +499,9 @@ trait LowerTypeKind {
499499}
500500
501501trait LowerParameterMap {
502- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>>;
502+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>>;
503503 fn declared_parameters(&self) -> &[ParameterKind];
504- fn all_parameters(&self) -> Vec<chalk_ir::ParameterKind<Ident>> {
504+ fn all_parameters(&self) -> Vec<chalk_ir::ParameterKind<ChalkIr, Ident>> {
505505 self.synthetic_parameters()
506506 .into_iter()
507507 .chain(self.declared_parameters().iter().map(|id| id.lower()))
@@ -550,7 +550,7 @@ trait LowerParameterMap {
550550}
551551
552552impl LowerParameterMap for StructDefn {
553- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
553+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
554554 None
555555 }
556556
@@ -560,7 +560,7 @@ impl LowerParameterMap for StructDefn {
560560}
561561
562562impl LowerParameterMap for Impl {
563- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
563+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
564564 None
565565 }
566566
@@ -570,7 +570,7 @@ impl LowerParameterMap for Impl {
570570}
571571
572572impl LowerParameterMap for AssocTyDefn {
573- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
573+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
574574 None
575575 }
576576
@@ -580,7 +580,7 @@ impl LowerParameterMap for AssocTyDefn {
580580}
581581
582582impl LowerParameterMap for AssocTyValue {
583- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
583+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
584584 None
585585 }
586586
@@ -590,7 +590,7 @@ impl LowerParameterMap for AssocTyValue {
590590}
591591
592592impl LowerParameterMap for TraitDefn {
593- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
593+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
594594 Some(chalk_ir::ParameterKind::Ty(intern(SELF)))
595595 }
596596
@@ -600,7 +600,7 @@ impl LowerParameterMap for TraitDefn {
600600}
601601
602602impl LowerParameterMap for Clause {
603- fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<Ident>> {
603+ fn synthetic_parameters(&self) -> Option<chalk_ir::ParameterKind<ChalkIr, Ident>> {
604604 None
605605 }
606606
@@ -609,16 +609,28 @@ impl LowerParameterMap for Clause {
609609 }
610610}
611611
612+ fn get_type_of_u32() -> chalk_ir::Ty<ChalkIr> {
613+ chalk_ir::ApplicationTy {
614+ name: chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::U32)),
615+ substitution: Substitution::empty(&ChalkIr),
616+ }
617+ .cast(&ChalkIr)
618+ .intern(&ChalkIr)
619+ }
620+
612621trait LowerParameterKind {
613- fn lower(&self) -> chalk_ir::ParameterKind<Ident>;
622+ fn lower(&self) -> chalk_ir::ParameterKind<ChalkIr, Ident>;
614623}
615624
616625impl LowerParameterKind for ParameterKind {
617- fn lower(&self) -> chalk_ir::ParameterKind<Ident> {
626+ fn lower(&self) -> chalk_ir::ParameterKind<ChalkIr, Ident> {
618627 match *self {
619628 ParameterKind::Ty(ref n) => chalk_ir::ParameterKind::Ty(n.str),
620629 ParameterKind::Lifetime(ref n) => chalk_ir::ParameterKind::Lifetime(n.str),
621- ParameterKind::Const(ref n) => chalk_ir::ParameterKind::Const(n.str),
630+ ParameterKind::Const(ref n) => chalk_ir::ParameterKind::Const {
631+ ty: get_type_of_u32(),
632+ value: n.str,
633+ },
622634 }
623635 }
624636}
@@ -1233,9 +1245,10 @@ impl LowerParameter for Parameter {
12331245 Parameter::Ty(ref t) => Ok(t.lower(env)?.cast(interner)),
12341246 Parameter::Lifetime(ref l) => Ok(l.lower(env)?.cast(interner)),
12351247 Parameter::Id(name) => env.lookup_parameter(name),
1236- Parameter::ConstValue(value) => Ok(chalk_ir::ConstData::Concrete(
1237- chalk_ir::ConcreteConst { interned: value },
1238- )
1248+ Parameter::ConstValue(value) => Ok(chalk_ir::ConstData {
1249+ ty: get_type_of_u32(),
1250+ value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: value }),
1251+ }
12391252 .intern(interner)
12401253 .cast(interner)),
12411254 }
@@ -1560,12 +1573,12 @@ impl Kinded for ParameterKind {
15601573 }
15611574}
15621575
1563- impl<T, L, C> Kinded for chalk_ir::ParameterKind<T, L, C> {
1576+ impl<I: chalk_ir::interner::Interner, T, L, C> Kinded for chalk_ir::ParameterKind<I, T, L, C> {
15641577 fn kind(&self) -> Kind {
15651578 match *self {
15661579 chalk_ir::ParameterKind::Ty(_) => Kind::Ty,
15671580 chalk_ir::ParameterKind::Lifetime(_) => Kind::Lifetime,
1568- chalk_ir::ParameterKind::Const(_) => Kind::Const,
1581+ chalk_ir::ParameterKind::Const { .. } => Kind::Const,
15691582 }
15701583 }
15711584}
0 commit comments