Skip to content

Commit 8efa0fa

Browse files
committed
Parse reference types
1 parent fd68560 commit 8efa0fa

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

chalk-parse/src/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ pub enum Ty {
197197
mutability: Mutability,
198198
ty: Box<Ty>,
199199
},
200+
Ref {
201+
mutability: Mutability,
202+
lifetime: Lifetime,
203+
ty: Box<Ty>,
204+
},
200205
}
201206

202207
#[derive(Copy, Clone, PartialEq, Eq, Debug)]

chalk-parse/src/parser.lalrpop

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ TyWithoutFor: Ty = {
205205
<n:Id> "<" <a:Comma<Parameter>> ">" => Ty::Apply { name: n, args: a },
206206
<p:ProjectionTy> => Ty::Projection { proj: p },
207207
"(" <t:TupleOrParensInner> ")" => t,
208-
"*" <m: Mutability> <t:Ty> => Ty::Raw{ mutability: m, ty: Box::new(t) },
208+
"*" <m: RawMutability> <t:Ty> => Ty::Raw{ mutability: m, ty: Box::new(t) },
209+
"&" <l: Lifetime> "mut" <t:Ty> => Ty::Ref{ mutability: Mutability::Mut, lifetime: l, ty: Box::new(t) },
210+
"&" <l: Lifetime> <t:Ty> => Ty::Ref{ mutability: Mutability::Not, lifetime: l, ty: Box::new(t) },
209211
};
210212

211213
ScalarType: ScalarType = {
@@ -238,7 +240,7 @@ TupleOrParensInner: Ty = {
238240
() => Ty::Tuple { types: vec![] },
239241
};
240242

241-
Mutability: Mutability = {
243+
RawMutability: Mutability = {
242244
"mut" => Mutability::Mut,
243245
"const" => Mutability::Not,
244246
};

0 commit comments

Comments
 (0)