<p dir="auto">I would have expected this to work,  but it does not:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#[feature(macro_rules)];

macro_rules! test {
    () =&gt; {
        fn foo();
    }
}

trait Foo {
    test!()
}"><pre class="notranslate"><span class="pl-c1">#<span class="pl-kos">[</span>feature<span class="pl-kos">(</span>macro_rules<span class="pl-kos">)</span><span class="pl-kos">]</span></span><span class="pl-kos">;</span>

<span class="pl-k">macro_rules!</span> test <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-kos">)</span> =&gt; <span class="pl-kos">{</span>
        <span class="pl-k">fn</span> foo<span class="pl-kos">(</span><span class="pl-kos">)</span>;
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">trait</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
    <span class="pl-en">test</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Currently fails with this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test.rs:10:4: 10:8 error: unexpected token: `test`
test.rs:10     test!()
               ^~~~
task 'rustc' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/libsyntax/diagnostic.rs:76
task '&lt;main&gt;' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/librustc/lib.rs:441"><pre class="notranslate"><code class="notranslate">test.rs:10:4: 10:8 error: unexpected token: `test`
test.rs:10     test!()
               ^~~~
task 'rustc' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/libsyntax/diagnostic.rs:76
task '&lt;main&gt;' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/librustc/lib.rs:441
</code></pre></div>
<p dir="auto">The following code produces an ICE (using the latest nightly)</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="macro_rules! width(
    ($this:expr) =&gt; {
        $this.width.unwrap()
    }
);

struct HasInfo {
    width: Option&lt;usize&gt;
}

impl HasInfo {
    fn get_size(&amp;mut self, n: usize) -&gt; usize {
        n
    }

    fn get_other(&amp;mut self) -&gt; usize {
        self.get_size(width!(self))
    }
}

fn main() {
    println!(&quot;hello?&quot;);
}"><pre class="notranslate"><span class="pl-k">macro_rules!</span> width<span class="pl-kos">(</span>
    <span class="pl-kos">(</span>$this<span class="pl-kos">:</span>expr<span class="pl-kos">)</span> =&gt; <span class="pl-kos">{</span>
        $this.width.unwrap<span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">struct</span> <span class="pl-smi">HasInfo</span> <span class="pl-kos">{</span>
    <span class="pl-c1">width</span><span class="pl-kos">:</span> <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-smi">usize</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">HasInfo</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">get_size</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">,</span> <span class="pl-s1">n</span><span class="pl-kos">:</span> <span class="pl-smi">usize</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">usize</span> <span class="pl-kos">{</span>
        n
    <span class="pl-kos">}</span>

    <span class="pl-k">fn</span> <span class="pl-en">get_other</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">usize</span> <span class="pl-kos">{</span>
        <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-en">get_size</span><span class="pl-kos">(</span><span class="pl-en">width</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-smi">self</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"hello?"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ RUST_BACKTRACE=1 rustc test.rs
test.rs:17:30: 3:20 error: cannot use `self.width` because it was mutably borrowed
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/option.rs:330

stack backtrace:
   1:        0x10834491f - sys::backtrace::write::hbd92b2f3b9d1f59bh7r
   2:        0x10834cf80 - panicking::on_panic::hdc2c5977e67a233aUlw
   3:        0x108308105 - rt::unwind::begin_unwind_inner::h01673f860cb84cd8D3v
   4:        0x108308f3c - rt::unwind::begin_unwind_fmt::h9151fe47c4b99bcdJ2v
   5:        0x10834cadc - rust_begin_unwind
   6:        0x10839c7f5 - panicking::panic_fmt::he085f3b18c15d040hJy
   7:        0x107ab1183 - codemap::CodeMap::span_to_lines::hb2f0d1a92c447e1btLA
   8:        0x107af89eb - diagnostic::emit::h0cb83e197668e62aspC
   9:        0x107af631c - diagnostic::EmitterWriter.Emitter::emit::h514d00ff1c0c52feamC
  10:        0x107aa7969 - diagnostic::SpanHandler::span_err::h2e7e4e702a3c83e0gSB
  11:        0x1054c5c43 - session::Session::span_err::hb309dbdc83438db3WGq
  12:        0x104f015f4 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;::consume_common::h37627587e5d63ecfQWa
  13:        0x104f00fd1 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::consume::h70f8cd9f17ba9508Bea
  14:        0x104f1530a - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  15:        0x104f11f2e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::walk_expr::h15228336715392409603
  16:        0x104f1531e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  17:        0x104f11f2e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::walk_expr::h15228336715392409603
  18:        0x104f1531e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  19:        0x104f30aef - borrowck::borrowck_fn::h4c8fd678dfdeee49NOe
  20:        0x104f300dc - borrowck::BorrowckCtxt&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_fn::h55da20bf55e34495bGe
  21:        0x104f32ab4 - visit::walk_impl_item::h12505514548441264404
  22:        0x104f3378a - visit::walk_item::h2754692921043539544
  23:        0x104f32c08 - borrowck::check_crate::h3db16b6efa27d8adQIe
  24:        0x104a9b880 - driver::phase_3_run_analysis_passes::hba2077d3401024fbtGa
  25:        0x104a7bd5c - driver::compile_input::hddc4eab8e7fc8420Qba
  26:        0x104b3ac83 - run_compiler::hf4a5110b6d35543565b
  27:        0x104b383ea - boxed::F.FnBox&lt;A&gt;::call_box::h8166354692369242215
  28:        0x104b37947 - rt::unwind::try::try_fn::h645230996156021718
  29:        0x1083cf488 - rust_try_inner
  30:        0x1083cf475 - rust_try
  31:        0x104b37c1d - boxed::F.FnBox&lt;A&gt;::call_box::h7235942386744103169
  32:        0x10834b97d - sys::thread::Thread::new::thread_start::h7bede09625198736Cov
  33:     0x7fff8b475267 - _pthread_body
  34:     0x7fff8b4751e4 - _pthread_start"><pre class="notranslate"><code class="notranslate">$ RUST_BACKTRACE=1 rustc test.rs
test.rs:17:30: 3:20 error: cannot use `self.width` because it was mutably borrowed
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcore/option.rs:330

stack backtrace:
   1:        0x10834491f - sys::backtrace::write::hbd92b2f3b9d1f59bh7r
   2:        0x10834cf80 - panicking::on_panic::hdc2c5977e67a233aUlw
   3:        0x108308105 - rt::unwind::begin_unwind_inner::h01673f860cb84cd8D3v
   4:        0x108308f3c - rt::unwind::begin_unwind_fmt::h9151fe47c4b99bcdJ2v
   5:        0x10834cadc - rust_begin_unwind
   6:        0x10839c7f5 - panicking::panic_fmt::he085f3b18c15d040hJy
   7:        0x107ab1183 - codemap::CodeMap::span_to_lines::hb2f0d1a92c447e1btLA
   8:        0x107af89eb - diagnostic::emit::h0cb83e197668e62aspC
   9:        0x107af631c - diagnostic::EmitterWriter.Emitter::emit::h514d00ff1c0c52feamC
  10:        0x107aa7969 - diagnostic::SpanHandler::span_err::h2e7e4e702a3c83e0gSB
  11:        0x1054c5c43 - session::Session::span_err::hb309dbdc83438db3WGq
  12:        0x104f015f4 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;::consume_common::h37627587e5d63ecfQWa
  13:        0x104f00fd1 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::consume::h70f8cd9f17ba9508Bea
  14:        0x104f1530a - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  15:        0x104f11f2e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::walk_expr::h15228336715392409603
  16:        0x104f1531e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  17:        0x104f11f2e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::walk_expr::h15228336715392409603
  18:        0x104f1531e - middle::expr_use_visitor::ExprUseVisitor&lt;'d, 't, 'tcx, TYPER&gt;::consume_expr::h15185387293697103588
  19:        0x104f30aef - borrowck::borrowck_fn::h4c8fd678dfdeee49NOe
  20:        0x104f300dc - borrowck::BorrowckCtxt&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_fn::h55da20bf55e34495bGe
  21:        0x104f32ab4 - visit::walk_impl_item::h12505514548441264404
  22:        0x104f3378a - visit::walk_item::h2754692921043539544
  23:        0x104f32c08 - borrowck::check_crate::h3db16b6efa27d8adQIe
  24:        0x104a9b880 - driver::phase_3_run_analysis_passes::hba2077d3401024fbtGa
  25:        0x104a7bd5c - driver::compile_input::hddc4eab8e7fc8420Qba
  26:        0x104b3ac83 - run_compiler::hf4a5110b6d35543565b
  27:        0x104b383ea - boxed::F.FnBox&lt;A&gt;::call_box::h8166354692369242215
  28:        0x104b37947 - rt::unwind::try::try_fn::h645230996156021718
  29:        0x1083cf488 - rust_try_inner
  30:        0x1083cf475 - rust_try
  31:        0x104b37c1d - boxed::F.FnBox&lt;A&gt;::call_box::h7235942386744103169
  32:        0x10834b97d - sys::thread::Thread::new::thread_start::h7bede09625198736Cov
  33:     0x7fff8b475267 - _pthread_body
  34:     0x7fff8b4751e4 - _pthread_start
</code></pre></div>
<p dir="auto">Probably an duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="75805042" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/25353" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/25353/hovercard" href="https://github.com/rust-lang/rust/issues/25353">#25353</a> or <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="70592189" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/24761" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/24761/hovercard" href="https://github.com/rust-lang/rust/issues/24761">#24761</a>. I opened a new bug since I was able to reduce it to a minimal example. This is not related to the borrow checker as it also crashes if I change <code class="notranslate">$this.width</code> to <code class="notranslate">$this.undefined</code>.</p>