Skip to content

Commit 499d492

Browse files
authored
Merge pull request #393 from Areredify/const
const generics support
2 parents c0daf93 + 6399335 commit 499d492

35 files changed

+1433
-429
lines changed

chalk-integration/src/error.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ impl std::error::Error for ChalkError {}
5454

5555
#[derive(Debug)]
5656
pub enum RustIrError {
57-
InvalidTypeName(Identifier),
58-
InvalidLifetimeName(Identifier),
57+
InvalidParameterName(Identifier),
58+
InvalidTraitName(Identifier),
5959
NotTrait(Identifier),
6060
NotStruct(Identifier),
6161
DuplicateOrShadowedParameters,
@@ -96,8 +96,10 @@ pub enum RustIrError {
9696
impl std::fmt::Display for RustIrError {
9797
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9898
match self {
99-
RustIrError::InvalidTypeName(name) => write!(f, "invalid type name `{}`", name),
100-
RustIrError::InvalidLifetimeName(name) => write!(f, "invalid lifetime name `{}`", name),
99+
RustIrError::InvalidParameterName(name) => {
100+
write!(f, "invalid parameter name `{}`", name)
101+
}
102+
RustIrError::InvalidTraitName(name) => write!(f, "invalid trait name `{}`", name),
101103
RustIrError::NotTrait(name) => write!(
102104
f,
103105
"expected a trait, found `{}`, which is not a trait",

chalk-integration/src/interner.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::tls;
22
use chalk_ir::interner::{HasInterner, Interner};
33
use chalk_ir::{
4-
AdtId, AliasTy, ApplicationTy, AssocTypeId, CanonicalVarKind, CanonicalVarKinds, Goals,
5-
Lifetime, OpaqueTy, OpaqueTyId, ProgramClauseImplication, ProgramClauses, ProjectionTy,
4+
AdtId, AliasTy, ApplicationTy, AssocTypeId, CanonicalVarKind, CanonicalVarKinds, ConstData,
5+
Goals, Lifetime, OpaqueTy, OpaqueTyId, ProgramClauseImplication, ProgramClauses, ProjectionTy,
66
QuantifiedWhereClauses, SeparatorTraitRef, Substitution, TraitId, Ty, VariableKind,
77
VariableKinds,
88
};
@@ -36,6 +36,8 @@ pub struct ChalkIr;
3636
impl Interner for ChalkIr {
3737
type InternedType = Arc<TyData<ChalkIr>>;
3838
type InternedLifetime = LifetimeData<ChalkIr>;
39+
type InternedConst = Arc<ConstData<ChalkIr>>;
40+
type InternedConcreteConst = u32;
3941
type InternedGenericArg = GenericArgData<ChalkIr>;
4042
type InternedGoal = Arc<GoalData<ChalkIr>>;
4143
type InternedGoals = Vec<Goal<ChalkIr>>;
@@ -214,6 +216,18 @@ impl Interner for ChalkIr {
214216
lifetime
215217
}
216218

219+
fn intern_const(&self, constant: ConstData<ChalkIr>) -> Arc<ConstData<ChalkIr>> {
220+
Arc::new(constant)
221+
}
222+
223+
fn const_data<'a>(&self, constant: &'a Arc<ConstData<ChalkIr>>) -> &'a ConstData<ChalkIr> {
224+
constant
225+
}
226+
227+
fn const_eq(&self, _ty: &Arc<TyData<ChalkIr>>, c1: &u32, c2: &u32) -> bool {
228+
c1 == c2
229+
}
230+
217231
fn intern_generic_arg(&self, generic_arg: GenericArgData<ChalkIr>) -> GenericArgData<ChalkIr> {
218232
generic_arg
219233
}

0 commit comments

Comments
 (0)