<p dir="auto">Example: <a href="http://is.gd/9LFIF2" rel="nofollow">http://is.gd/9LFIF2</a></p>
<p dir="auto">The outer macro attempts to parse the new variables as existing ones, and errors when it can't find them.</p>
<p dir="auto">This is a FIXME issue; currently, macro invocations are parsed too eagerly. In particular, the current system decides before expansion time whether a rhs pattern-use (e.g. $y) is bound or unbound. This is incompatible with macro-producing macros that use a given identifier in a pattern position. It's also incompatible with macros inside macros, where inner binding patterns are believed to be pattern uses. The solution is to delay this decision until the macro is encountered at expansion-time, by which time all outer macros have been expanded.</p>
<p dir="auto">Here's an example of a macro that doesn't work in the current system:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// the z flows into and out of two macros (g &amp; f) along one path, and one (just g) along the
// other, so the result of the whole thing should be &quot;let z_123 = 3; z_123
macro_rules! g (
    ($x:ident) =&gt;
    (
        {macro_rules! f(
            ($y:ident)=&gt;({let $y=3;$x})
        );
         f!($x)})
)

fn a(){g!(z)}"><pre class="notranslate"><code class="notranslate">// the z flows into and out of two macros (g &amp; f) along one path, and one (just g) along the
// other, so the result of the whole thing should be "let z_123 = 3; z_123
macro_rules! g (
    ($x:ident) =&gt;
    (
        {macro_rules! f(
            ($y:ident)=&gt;({let $y=3;$x})
        );
         f!($x)})
)

fn a(){g!(z)}
</code></pre></div>
<p dir="auto">Trying to expand this yields this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Running /usr/local/bin/rustc:
/tmp/g.rs:7:12: 7:13 error: unknown macro variable `y`
/tmp/g.rs:7             ($y:ident)=&gt;({let $y=3;$x})
                        ^"><pre class="notranslate"><code class="notranslate">Running /usr/local/bin/rustc:
/tmp/g.rs:7:12: 7:13 error: unknown macro variable `y`
/tmp/g.rs:7             ($y:ident)=&gt;({let $y=3;$x})
                        ^
</code></pre></div>
<p dir="auto">... indicating that the $y is believed to be a use, rather than a binder.</p>