Skip to content

Commit 3400b1a

Browse files
committed
Add scalar and tuple to TypeName
1 parent 039fc90 commit 3400b1a

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

chalk-ir/src/debug.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ impl<I: Interner> Debug for TypeName<I> {
100100
match self {
101101
TypeName::Struct(id) => write!(fmt, "{:?}", id),
102102
TypeName::AssociatedType(assoc_ty) => write!(fmt, "{:?}", assoc_ty),
103+
TypeName::Scalar(scalar) => write!(fmt, "{:?}", scalar),
104+
TypeName::Tuple(arity) => write!(fmt, "{:?}", arity),
103105
TypeName::Error => write!(fmt, "{{error}}"),
104106
}
105107
}

chalk-ir/src/fold/boring_impls.rs

+4
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ copy_fold!(DebruijnIndex);
200200
copy_fold!(chalk_engine::TableIndex);
201201
copy_fold!(chalk_engine::TimeStamp);
202202
copy_fold!(());
203+
copy_fold!(UintTy);
204+
copy_fold!(IntTy);
205+
copy_fold!(FloatTy);
206+
copy_fold!(Scalar);
203207

204208
#[macro_export]
205209
macro_rules! id_fold {

chalk-ir/src/lib.rs

+41
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,41 @@ impl<G: HasInterner> HasInterner for InEnvironment<G> {
9696
type Interner = G::Interner;
9797
}
9898

99+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
100+
pub enum IntTy {
101+
Isize,
102+
I8,
103+
I16,
104+
I32,
105+
I64,
106+
I128,
107+
}
108+
109+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
110+
pub enum UintTy {
111+
Usize,
112+
U8,
113+
U16,
114+
U32,
115+
U64,
116+
U128,
117+
}
118+
119+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
120+
pub enum FloatTy {
121+
F32,
122+
F64,
123+
}
124+
125+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
126+
pub enum Scalar {
127+
Bool,
128+
Char,
129+
Int(IntTy),
130+
Uint(UintTy),
131+
Float(FloatTy),
132+
}
133+
99134
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Fold)]
100135
pub enum TypeName<I: Interner> {
101136
/// a type like `Vec<T>`
@@ -104,6 +139,12 @@ pub enum TypeName<I: Interner> {
104139
/// an associated type like `Iterator::Item`; see `AssociatedType` for details
105140
AssociatedType(AssocTypeId<I>),
106141

142+
/// a scalar type like `bool` or `u32`
143+
Scalar(Scalar),
144+
145+
/// a tuple of the given arity
146+
Tuple(usize),
147+
107148
/// This can be used to represent an error, e.g. during name resolution of a type.
108149
/// Chalk itself will not produce this, just pass it through when given.
109150
Error,

chalk-solve/src/clauses.rs

+2
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ fn match_type_name<I: Interner>(builder: &mut ClauseBuilder<'_, I>, name: TypeNa
381381
.db
382382
.associated_ty_data(type_id)
383383
.to_program_clauses(builder),
384+
TypeName::Scalar(_) => todo!("Scalar match type name"),
385+
TypeName::Tuple(_) => todo!("Tuple match type name"),
384386
}
385387
}
386388

0 commit comments

Comments
 (0)