Macro rustc_mir_build::build::custom::parse::parse_by_kind
source · macro_rules! parse_by_kind {
(
$self:ident,
$expr_id:expr,
$expr_name:pat,
$expected:literal,
$(
@call($name:literal, $args:ident) => $call_expr:expr,
)*
$(
$pat:pat => $expr:expr,
)*
) => { ... };
}
Expand description
Helper macro for parsing custom MIR.
Example usage looks something like:
ⓘ
parse_by_kind!(
self, // : &ParseCtxt
expr_id, // what you're matching against
"assignment", // the thing you're trying to parse
@call("mir_assign", args) => { args[0] }, // match invocations of the `mir_assign` special function
ExprKind::Assign { lhs, .. } => { lhs }, // match thir assignment expressions
// no need for fallthrough case - reasonable error is automatically generated
)