conlang: Self is not a type, it's a path to a type
This commit is contained in:
@@ -252,7 +252,6 @@ pub struct Ty {
|
||||
pub enum TyKind {
|
||||
Never,
|
||||
Empty,
|
||||
SelfTy,
|
||||
Path(Path),
|
||||
Tuple(TyTuple),
|
||||
Ref(TyRef),
|
||||
@@ -293,6 +292,7 @@ pub struct Path {
|
||||
pub enum PathPart {
|
||||
SuperKw,
|
||||
SelfKw,
|
||||
SelfTy,
|
||||
Ident(Sym),
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,6 @@ mod display {
|
||||
match self {
|
||||
TyKind::Never => "!".fmt(f),
|
||||
TyKind::Empty => "()".fmt(f),
|
||||
TyKind::SelfTy => "Self".fmt(f),
|
||||
TyKind::Path(v) => v.fmt(f),
|
||||
TyKind::Tuple(v) => v.fmt(f),
|
||||
TyKind::Ref(v) => v.fmt(f),
|
||||
@@ -357,6 +356,7 @@ mod display {
|
||||
match self {
|
||||
PathPart::SuperKw => "super".fmt(f),
|
||||
PathPart::SelfKw => "self".fmt(f),
|
||||
PathPart::SelfTy => "Self".fmt(f),
|
||||
PathPart::Ident(id) => id.fmt(f),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ pub trait Fold {
|
||||
match p {
|
||||
PathPart::SuperKw => PathPart::SuperKw,
|
||||
PathPart::SelfKw => PathPart::SelfKw,
|
||||
PathPart::SelfTy => PathPart::SelfTy,
|
||||
PathPart::Ident(i) => PathPart::Ident(self.fold_sym(i)),
|
||||
}
|
||||
}
|
||||
@@ -498,7 +499,6 @@ pub fn or_fold_ty_kind<F: Fold + ?Sized>(folder: &mut F, kind: TyKind) -> TyKind
|
||||
match kind {
|
||||
TyKind::Never => TyKind::Never,
|
||||
TyKind::Empty => TyKind::Empty,
|
||||
TyKind::SelfTy => TyKind::SelfTy,
|
||||
TyKind::Path(p) => TyKind::Path(folder.fold_path(p)),
|
||||
TyKind::Tuple(t) => TyKind::Tuple(folder.fold_ty_tuple(t)),
|
||||
TyKind::Ref(t) => TyKind::Ref(folder.fold_ty_ref(t)),
|
||||
|
||||
@@ -169,6 +169,7 @@ pub trait Visit<'a>: Sized {
|
||||
match p {
|
||||
PathPart::SuperKw => {}
|
||||
PathPart::SelfKw => {}
|
||||
PathPart::SelfTy => {}
|
||||
PathPart::Ident(i) => self.visit_sym(i),
|
||||
}
|
||||
}
|
||||
@@ -422,7 +423,6 @@ pub fn or_visit_ty_kind<'a, V: Visit<'a>>(visitor: &mut V, kind: &'a TyKind) {
|
||||
match kind {
|
||||
TyKind::Never => {}
|
||||
TyKind::Empty => {}
|
||||
TyKind::SelfTy => {}
|
||||
TyKind::Path(p) => visitor.visit_path(p),
|
||||
TyKind::Tuple(t) => visitor.visit_ty_tuple(t),
|
||||
TyKind::Ref(t) => visitor.visit_ty_ref(t),
|
||||
|
||||
Reference in New Issue
Block a user