Skip to content

Commit e925574

Browse files
committed
Parse and lower slice types
1 parent c583ccb commit e925574

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

chalk-integration/src/lowering.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,15 @@ impl LowerTy for Ty {
12111211
})
12121212
.intern(interner)),
12131213

1214+
Ty::Slice { ty } => Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy {
1215+
name: chalk_ir::TypeName::Slice,
1216+
substitution: chalk_ir::Substitution::from_fallible(
1217+
interner,
1218+
std::iter::once(ty.lower(env)),
1219+
)?,
1220+
})
1221+
.intern(interner)),
1222+
12141223
Ty::Raw { mutability, ty } => Ok(chalk_ir::TyData::Apply(chalk_ir::ApplicationTy {
12151224
name: chalk_ir::TypeName::Raw(ast_mutability_to_chalk_mutability(
12161225
mutability.clone(),

chalk-parse/src/ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ pub enum Ty {
193193
Scalar {
194194
ty: ScalarType,
195195
},
196+
Slice {
197+
ty: Box<Ty>,
198+
},
196199
Raw {
197200
mutability: Mutability,
198201
ty: Box<Ty>,

chalk-parse/src/parser.lalrpop

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ TyWithoutFor: Ty = {
208208
"*" <m: RawMutability> <t:Ty> => Ty::Raw{ mutability: m, ty: Box::new(t) },
209209
"&" <l: Lifetime> "mut" <t:Ty> => Ty::Ref{ mutability: Mutability::Mut, lifetime: l, ty: Box::new(t) },
210210
"&" <l: Lifetime> <t:Ty> => Ty::Ref{ mutability: Mutability::Not, lifetime: l, ty: Box::new(t) },
211+
"[" <t:Ty> "]" => Ty::Slice { ty: Box::new(t) },
211212
};
212213

213214
ScalarType: ScalarType = {

0 commit comments

Comments
 (0)