Skip to content

Commit 7a4bd7f

Browse files
committed
Add associated consts to parsing
1 parent a9e453e commit 7a4bd7f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

chalk-parse/src/ast.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub struct TraitDefn {
142142
pub variable_kinds: Vec<VariableKind>,
143143
pub where_clauses: Vec<QuantifiedWhereClause>,
144144
pub assoc_ty_defns: Vec<AssocTyDefn>,
145+
pub assoc_const_defns: Vec<AssocConstDefn>,
145146
pub flags: TraitFlags,
146147
pub well_known: Option<WellKnownTrait>,
147148
}
@@ -182,6 +183,12 @@ pub struct AssocTyDefn {
182183
pub where_clauses: Vec<QuantifiedWhereClause>,
183184
}
184185

186+
#[derive(Clone, PartialEq, Eq, Debug)]
187+
pub struct AssocConstDefn {
188+
pub name: Identifier,
189+
pub ty: Ty,
190+
}
191+
185192
#[derive(Clone, PartialEq, Eq, Debug)]
186193
pub struct OpaqueTyDefn {
187194
pub ty: Ty,

chalk-parse/src/parser.lalrpop

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,13 @@ ClosureArgs: Vec<Ty> = {
257257

258258
TraitDefn: TraitDefn = {
259259
<auto:AutoKeyword?> <marker:MarkerKeyword?> <upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> <non_enumerable:NonEnumerableKeyword?> <coinductive:CoinductiveKeyword?> <object_safe:ObjectSafeKeyword?> <well_known:WellKnownTrait?> "trait" <n:Id><p:Angle<VariableKind>>
260-
<w:QuantifiedWhereClauses> "{" <a:AssocTyDefn*> "}" => TraitDefn
260+
<w:QuantifiedWhereClauses> "{" <a:AssocTyDefn*> <ac:AssocConstDefn*> "}" => TraitDefn
261261
{
262262
name: n,
263263
variable_kinds: p,
264264
where_clauses: w,
265265
assoc_ty_defns: a,
266+
assoc_const_defns: ac,
266267
well_known,
267268
flags: TraitFlags {
268269
auto: auto.is_some(),
@@ -289,6 +290,15 @@ AssocTyDefn: AssocTyDefn = {
289290
}
290291
};
291292

293+
AssocConstDefn: AssocConstDefn = {
294+
"const" <name:Id> ":" <ty:Ty> ";" => {
295+
AssocConstDefn {
296+
name: name,
297+
ty: ty,
298+
}
299+
}
300+
};
301+
292302
OpaqueTyDefn: OpaqueTyDefn = {
293303
"opaque" "type" <name:Id> <p:Angle<VariableKind>> <b:(":" <Plus<QuantifiedInlineBound>>)?>
294304
<w:QuantifiedWhereClauses> "=" <ty:Ty> ";" => {

0 commit comments

Comments
 (0)