Simplify thir_with_elements
macro.
The `field_name`/`field_ty` don't need to be parameters, they can be hardcoded.
This commit is contained in:
parent
6d03fa7519
commit
0be280e52f
1 changed files with 3 additions and 13 deletions
|
@ -37,9 +37,6 @@ pub mod visit;
|
|||
|
||||
macro_rules! thir_with_elements {
|
||||
(
|
||||
$($field_name:ident: $field_ty:ty,)*
|
||||
|
||||
@elements:
|
||||
$($name:ident: $id:ty => $value:ty => $format:literal,)*
|
||||
) => {
|
||||
$(
|
||||
|
@ -55,20 +52,16 @@ macro_rules! thir_with_elements {
|
|||
/// This can be indexed directly by any THIR index (e.g. [`ExprId`]).
|
||||
#[derive(Debug, HashStable, Clone)]
|
||||
pub struct Thir<'tcx> {
|
||||
$(
|
||||
pub $field_name: $field_ty,
|
||||
)*
|
||||
pub body_type: BodyTy<'tcx>,
|
||||
$(
|
||||
pub $name: IndexVec<$id, $value>,
|
||||
)*
|
||||
}
|
||||
|
||||
impl<'tcx> Thir<'tcx> {
|
||||
pub fn new($($field_name: $field_ty,)*) -> Thir<'tcx> {
|
||||
pub fn new(body_type: BodyTy<'tcx>) -> Thir<'tcx> {
|
||||
Thir {
|
||||
$(
|
||||
$field_name,
|
||||
)*
|
||||
body_type,
|
||||
$(
|
||||
$name: IndexVec::new(),
|
||||
)*
|
||||
|
@ -88,9 +81,6 @@ macro_rules! thir_with_elements {
|
|||
}
|
||||
|
||||
thir_with_elements! {
|
||||
body_type: BodyTy<'tcx>,
|
||||
|
||||
@elements:
|
||||
arms: ArmId => Arm<'tcx> => "a{}",
|
||||
blocks: BlockId => Block => "b{}",
|
||||
exprs: ExprId => Expr<'tcx> => "e{}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue