ast: add ptr patterns
This commit is contained in:
@@ -92,6 +92,8 @@ pub enum PatOp {
|
|||||||
Mut,
|
Mut,
|
||||||
/// Matches the dereference of a pointer (`&pat`)
|
/// Matches the dereference of a pointer (`&pat`)
|
||||||
Ref,
|
Ref,
|
||||||
|
/// Matches the dereference of a raw pointer (`*pat`)
|
||||||
|
Ptr,
|
||||||
/// Matches a partial decomposition (`..rest`) or upper-bounded range (`..100`)
|
/// Matches a partial decomposition (`..rest`) or upper-bounded range (`..100`)
|
||||||
Rest,
|
Rest,
|
||||||
/// Matches an exclusive bounded range (`0..100`)
|
/// Matches an exclusive bounded range (`0..100`)
|
||||||
@@ -176,7 +178,7 @@ pub enum TypedefKind {
|
|||||||
pub enum Expr<A: Annotation = Span> {
|
pub enum Expr<A: Annotation = Span> {
|
||||||
/// An identifier
|
/// An identifier
|
||||||
Id(FqPath),
|
Id(FqPath),
|
||||||
/// A meta-identifier
|
/// An escaped token for macro binding
|
||||||
MetId(String),
|
MetId(String),
|
||||||
/// A literal bool, string, char, or int
|
/// A literal bool, string, char, or int
|
||||||
Lit(Literal),
|
Lit(Literal),
|
||||||
@@ -577,6 +579,7 @@ impl Display for PatOp {
|
|||||||
Self::Pub => "pub ",
|
Self::Pub => "pub ",
|
||||||
Self::Mut => "mut ",
|
Self::Mut => "mut ",
|
||||||
Self::Ref => "&",
|
Self::Ref => "&",
|
||||||
|
Self::Ptr => "*",
|
||||||
Self::Rest => "..",
|
Self::Rest => "..",
|
||||||
Self::RangeEx => "..",
|
Self::RangeEx => "..",
|
||||||
Self::RangeIn => "..=",
|
Self::RangeIn => "..=",
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ impl<'t> Parse<'t> for Pat {
|
|||||||
TKind::Bar => p.consume().parse(level)?,
|
TKind::Bar => p.consume().parse(level)?,
|
||||||
TKind::Bang => p.consume().then(Pat::Never),
|
TKind::Bang => p.consume().then(Pat::Never),
|
||||||
TKind::Amp => Pat::Op(PatOp::Ref, vec![p.consume().parse(PPrec::Max)?]),
|
TKind::Amp => Pat::Op(PatOp::Ref, vec![p.consume().parse(PPrec::Max)?]),
|
||||||
|
TKind::Star => Pat::Op(PatOp::Ptr, vec![p.consume().parse(PPrec::Max)?]),
|
||||||
TKind::Mut => Pat::Op(PatOp::Mut, vec![p.consume().parse(PPrec::Max)?]),
|
TKind::Mut => Pat::Op(PatOp::Mut, vec![p.consume().parse(PPrec::Max)?]),
|
||||||
TKind::Pub => Pat::Op(PatOp::Pub, vec![p.consume().parse(PPrec::Max)?]),
|
TKind::Pub => Pat::Op(PatOp::Pub, vec![p.consume().parse(PPrec::Max)?]),
|
||||||
TKind::AmpAmp => Pat::Op(
|
TKind::AmpAmp => Pat::Op(
|
||||||
|
|||||||
Reference in New Issue
Block a user