cl-ast: Re-add(?) the Infer type-pattern

This commit is contained in:
2025-03-12 01:20:58 -05:00
parent 584207fc8c
commit 11c8daaed0
8 changed files with 20 additions and 5 deletions

View File

@@ -221,6 +221,7 @@ pub struct Ty {
pub enum TyKind {
Never,
Empty,
Infer,
Path(Path),
Array(TyArray),
Slice(TySlice),

View File

@@ -149,7 +149,7 @@ mod display {
' '.fmt(f)?;
write!(f.delimit(BRACES), "{items}")
}
None => Ok(())
None => Ok(()),
}
}
}
@@ -216,7 +216,7 @@ mod display {
let Self { name, variants: kind } = self;
write!(f, "enum {name}")?;
match kind {
Some(v) => separate(v, ",\n")(f.delimit(SPACED_BRACES)),
Some(v) => separate(v, ",\n")(f.delimit(SPACED_BRACES)),
None => ";".fmt(f),
}
}
@@ -290,6 +290,7 @@ mod display {
match self {
TyKind::Never => "!".fmt(f),
TyKind::Empty => "()".fmt(f),
TyKind::Infer => "_".fmt(f),
TyKind::Path(v) => v.fmt(f),
TyKind::Array(v) => v.fmt(f),
TyKind::Slice(v) => v.fmt(f),

View File

@@ -523,6 +523,7 @@ 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::Infer => TyKind::Infer,
TyKind::Path(p) => TyKind::Path(folder.fold_path(p)),
TyKind::Array(a) => TyKind::Array(folder.fold_ty_array(a)),
TyKind::Slice(s) => TyKind::Slice(folder.fold_ty_slice(s)),

View File

@@ -455,6 +455,7 @@ pub fn or_visit_ty_kind<'a, V: Visit<'a>>(visitor: &mut V, kind: &'a TyKind) {
match kind {
TyKind::Never => {}
TyKind::Empty => {}
TyKind::Infer => {}
TyKind::Path(p) => visitor.visit_path(p),
TyKind::Array(t) => visitor.visit_ty_array(t),
TyKind::Slice(t) => visitor.visit_ty_slice(t),