pub enum TypeDeclBody {
Variant {
leading_bar: Option<BarTok>,
first: VariantDef,
rest: Vec<BarVariantDef>,
},
Synonym(TypeExpr),
}Expand description
The right-hand side of a type declaration: either a variant’s
constructor list, or (transparently) a type-synonym body. Trying the
variant shape first is unambiguous: a type name is always a bare VAR
in this grammar (txbot), so no type expression can ever start with the
BarTok/CtorTok a variant list requires — any input that isn’t a
variant list falls through to Synonym cleanly, exactly like upstream’s
nxvariantdec telling variants (always CONSTRUCTOR-headed) apart
from txfunc by lookahead.
Variants§
Variant
[|] Ctor [of ty] (| Ctor [of ty])*.
Synonym(TypeExpr)
ty — a transparent type synonym, e.g. type point = length * length (typechecker.ml’s SynonymType/add_synonym: the name is
replaced by this body wherever it appears in type position, so it
never reaches unification itself). TypeDecl::tyvars is parsed the
same way for a synonym as for a variant (type 'a foo = ..), but
only the zero-param case can actually be referenced anywhere today
— this grammar has no applied-type-constructor syntax (TypeAtom’s
doc comment) to spell a synonym’s argument at a use site.
Trait Implementations§
Source§impl Clone for TypeDeclBody
impl Clone for TypeDeclBody
Source§fn clone(&self) -> TypeDeclBody
fn clone(&self) -> TypeDeclBody
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeDeclBody
impl Debug for TypeDeclBody
Source§impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TypeDeclBody
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TypeDeclBody
Source§type Error = ParseError<<__SyanMacro_Atom as Spanned>::Span>
type Error = ParseError<<__SyanMacro_Atom as Spanned>::Span>
<FieldTy as Parse<Atom>>::Error: Into<…> predicate re-creates a projection cycle on a
recursive field (E0275), which decycle’s bound-peeling does not break.