<p dir="auto">I want <code class="notranslate">mymacro!(bar)</code> to expand to <code class="notranslate">fn foo_bar() { }</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#[feature(macro_rules)];

macro_rules! mymacro( ($x:ident) =&gt; (
    fn concat_idents!(foo_, $x)() { }
))

mymacro!(bar)

fn main() {
    foo_bar();
}"><pre lang=".rs" class="notranslate"><code class="notranslate">#[feature(macro_rules)];

macro_rules! mymacro( ($x:ident) =&gt; (
    fn concat_idents!(foo_, $x)() { }
))

mymacro!(bar)

fn main() {
    foo_bar();
}
</code></pre></div>
<p dir="auto">gives</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="foo.rs:4:21: 4:22 error: expected `(` but found `!`
foo.rs:4     fn concat_idents!(foo_, $x)() { }"><pre class="notranslate"><code class="notranslate">foo.rs:4:21: 4:22 error: expected `(` but found `!`
foo.rs:4     fn concat_idents!(foo_, $x)() { }
</code></pre></div>
<p dir="auto">on</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 0.9 (d3b3c66 2014-01-12 19:44:26 -0700)
host: x86_64-unknown-linux-gnu"><pre class="notranslate"><code class="notranslate">rustc 0.9 (d3b3c66 2014-01-12 19:44:26 -0700)
host: x86_64-unknown-linux-gnu
</code></pre></div>
<p dir="auto">All of the examples below fail to compile with an error similar to the following:<br>
test.rs:1:16: 1:17 error: expected <code class="notranslate">(</code> but found <code class="notranslate">!</code><br>
test.rs:1 fn concat_idents!(foo, bar) () {}<br>
^</p>
<p dir="auto">fn concat_idents!(foo, bar) () {}<br>
trait concat_idents!(foo, bar) {}<br>
mod concat_idents!(foo, bar) {}<br>
let concat_idents!(foo, bar) = 0;</p>