# Understanding macro with \[\]

**URL:** <https://users.rust-lang.org/t/understanding-macro-with/59372>\
**Category:** uncategorized\
**Created:** [May 5, 2021, 5:58am UTC](https://users.rust-lang.org/t/understanding-macro-with/59372 "2021-05-05T05:58:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guerlando](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@guerlando](https://users.rust-lang.org/u/guerlando)\
**Post date:** [May 5, 2021, 5:58am UTC](https://users.rust-lang.org/t/understanding-macro-with/59372/1 "2021-05-05T05:58:13Z")

</div>

I'm trying to understand what this macro does: [rust/arena.rs at b25d3ba78118033b3f25b6de7a32e210d113872c · rust-lang/rust · GitHub](https://github.com/rust-lang/rust/blob/b25d3ba78118033b3f25b6de7a32e210d113872c/compiler/rustc_hir/src/arena.rs#L11)

```
#[macro_export]
macro_rules! arena_types {
    ($macro:path, $args:tt, $tcx:lifetime) => (
        $macro!($args, [
            // HIR types
            [few] hir_krate: rustc_hir::Crate<$tcx>,
            [] arm: rustc_hir::Arm<$tcx>,
            [] asm_operand: (rustc_hir::InlineAsmOperand<$tcx>, Span),
            [] asm_template: rustc_ast::InlineAsmTemplatePiece,
            [] attribute: rustc_ast::Attribute,
            [] block: rustc_hir::Block<$tcx>,
            [] bare_fn_ty: rustc_hir::BareFnTy<$tcx>,
            //...

```

It's called like this:

`rustc_hir::arena_types!(rustc_arena::declare_arena, [], 'tcx);`

Well, the first thing matched is a macro, the second is a [tokentree](https://doc.rust-lang.org/reference/macros-by-example.html) which I couldn't understand what exactly is but looks like things inside `[]` and the third is a lifetime.

Well, I understand that the `arena_types!` macro applies the matched macro with the arguments, but what is the things that come after the `$args`? What is ` [few] hir_krate: rustc_hir::Crate<$tcx>,`? I don't understand anything of here.

---

<div class="post-metadata">

**Author:** ![2e71828](https://avatars.discourse-cdn.com/v4/letter/2/3e96dc/32.png) [@2e71828](https://users.rust-lang.org/u/2e71828)\
**Post date:** [May 5, 2021, 6:46am UTC](https://users.rust-lang.org/t/understanding-macro-with/59372/2 "2021-05-05T06:46:50Z")

</div>

> [@guerlando](#):
>
> Well, I understand that the `arena_types!` macro applies the matched macro with the arguments, but what is the things that come after the `$args` ? What is ` [few] hir_krate: rustc_hir::Crate<$tcx>,` ?

This macro is building a call to the [`declare_arena`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_arena/macro.declare_arena.html) macro, which is sadly undocumented. There's no way to understand the contents of the `[]` as normal Rust code: it means whatever `declare_arena` decides that it means.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [August 3, 2021, 6:47am UTC](https://users.rust-lang.org/t/understanding-macro-with/59372/3 "2021-08-03T06:47:40Z")

</div>

Closed on August 3, 2021, 6:47am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
