ast: Add the "Self" type in preparation for cl-typeck
This commit is contained in:
parent
e3f08ac013
commit
5484d96e7d
@ -187,6 +187,7 @@ pub struct Ty {
|
|||||||
pub enum TyKind {
|
pub enum TyKind {
|
||||||
Never,
|
Never,
|
||||||
Empty,
|
Empty,
|
||||||
|
SelfTy,
|
||||||
Path(Path),
|
Path(Path),
|
||||||
Tuple(TyTuple),
|
Tuple(TyTuple),
|
||||||
Ref(TyRef),
|
Ref(TyRef),
|
||||||
|
@ -214,6 +214,7 @@ mod display {
|
|||||||
match &self.kind {
|
match &self.kind {
|
||||||
TyKind::Never => "!".fmt(f),
|
TyKind::Never => "!".fmt(f),
|
||||||
TyKind::Empty => "()".fmt(f),
|
TyKind::Empty => "()".fmt(f),
|
||||||
|
TyKind::SelfTy => "Self".fmt(f),
|
||||||
TyKind::Path(v) => v.fmt(f),
|
TyKind::Path(v) => v.fmt(f),
|
||||||
TyKind::Tuple(v) => v.fmt(f),
|
TyKind::Tuple(v) => v.fmt(f),
|
||||||
TyKind::Ref(v) => v.fmt(f),
|
TyKind::Ref(v) => v.fmt(f),
|
||||||
|
@ -676,6 +676,10 @@ impl<'t> Parser<'t> {
|
|||||||
self.consume_peeked();
|
self.consume_peeked();
|
||||||
TyKind::Never
|
TyKind::Never
|
||||||
}
|
}
|
||||||
|
Type::Keyword(Keyword::SelfTy) => {
|
||||||
|
self.consume_peeked();
|
||||||
|
TyKind::SelfTy
|
||||||
|
}
|
||||||
Type::Amp | Type::AmpAmp => self.tyref()?.into(),
|
Type::Amp | Type::AmpAmp => self.tyref()?.into(),
|
||||||
Type::LParen => self.tytuple()?.into(),
|
Type::LParen => self.tytuple()?.into(),
|
||||||
Type::Keyword(Keyword::Fn) => self.tyfn()?.into(),
|
Type::Keyword(Keyword::Fn) => self.tyfn()?.into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user