cl-ast: Let Ty handle the complexities of VariantKind::Tuple's type list
This commit is contained in:
parent
98868d3960
commit
83694988c3
@ -251,7 +251,7 @@ mod display {
|
|||||||
match self {
|
match self {
|
||||||
VariantKind::Plain => Ok(()),
|
VariantKind::Plain => Ok(()),
|
||||||
VariantKind::CLike(n) => write!(f, " = {n}"),
|
VariantKind::CLike(n) => write!(f, " = {n}"),
|
||||||
VariantKind::Tuple(v) => delimit(separate(v, ", "), INLINE_PARENS)(f),
|
VariantKind::Tuple(v) => v.fmt(f),
|
||||||
VariantKind::Struct(v) => delimit(separate(v, ", "), INLINE_BRACES)(f),
|
VariantKind::Struct(v) => delimit(separate(v, ", "), INLINE_BRACES)(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ pub struct Variant {
|
|||||||
pub enum VariantKind {
|
pub enum VariantKind {
|
||||||
Plain,
|
Plain,
|
||||||
CLike(u128),
|
CLike(u128),
|
||||||
Tuple(Vec<Ty>),
|
Tuple(Ty),
|
||||||
Struct(Vec<StructMember>),
|
Struct(Vec<StructMember>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,11 +565,15 @@ impl<'t> Parser<'t> {
|
|||||||
/// Parses a [tuple-like](VariantKind::Tuple) [`enum`](Enum) [Variant]
|
/// Parses a [tuple-like](VariantKind::Tuple) [`enum`](Enum) [Variant]
|
||||||
pub fn variantkind_tuple(&mut self) -> PResult<VariantKind> {
|
pub fn variantkind_tuple(&mut self) -> PResult<VariantKind> {
|
||||||
const PARSING: Parsing = Parsing::VariantKind;
|
const PARSING: Parsing = Parsing::VariantKind;
|
||||||
Ok(VariantKind::Tuple(delim(
|
let tup = self.ty()?;
|
||||||
sep(Self::ty, Punct::Comma, Punct::RParen, PARSING),
|
if !matches!(tup.kind, TyKind::Tuple(_) | TyKind::Empty) {
|
||||||
PARENS,
|
Err(self.error(
|
||||||
|
ErrorKind::ExpectedParsing { want: Parsing::TyTuple },
|
||||||
PARSING,
|
PARSING,
|
||||||
)(self)?))
|
))?
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(VariantKind::Tuple(tup))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_impl(&mut self) -> PResult<Impl> {
|
pub fn parse_impl(&mut self) -> PResult<Impl> {
|
||||||
|
Loading…
Reference in New Issue
Block a user