<p dir="auto">The specific error occurs in <a href="https://github.com/alexchandel/conrod/commit/b27fb8c7b58f1b67d9d4f963312bab8b3c53d1bf">this commit</a> on <a href="https://github.com/alexchandel/conrod">my bugfix fork</a> of <a href="https://github.com/PistonDevelopers/conrod">conrod</a>.</p>
<p dir="auto">An FnMut is created, boxed, and passed to a function that takes a Box&lt;FnMut(bool) + 'a&gt;. The closure modifies its environment:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="conrod/examples/all_widgets.rs:318:36: 318:97 error: internal compiler error: aliasability violation with closure
conrod/examples/all_widgets.rs:318                 .callback(Box::new(|&amp;mut: new_val: bool| {demo.bool_matrix[col][row] = new_val;}))
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"><pre class="notranslate">conrod/examples/all_widgets<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">318</span><span class="pl-kos">:</span><span class="pl-c1">36</span><span class="pl-kos">:</span> <span class="pl-c1">318</span><span class="pl-kos">:</span><span class="pl-c1">97</span> error<span class="pl-kos">:</span> internal compiler error<span class="pl-kos">:</span> aliasability violation with closure
conrod/examples/all_widgets<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">318</span>                 <span class="pl-kos">.</span><span class="pl-en">callback</span><span class="pl-kos">(</span><span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span>|<span class="pl-c1">&amp;</span><span class="pl-k">mut</span><span class="pl-kos">:</span> new_val<span class="pl-kos">:</span> <span class="pl-smi">bool</span>| <span class="pl-kos">{</span>demo<span class="pl-kos">.</span><span class="pl-c1">bool_matrix</span><span class="pl-kos">[</span>col<span class="pl-kos">]</span><span class="pl-kos">[</span>row<span class="pl-kos">]</span> = new_val<span class="pl-kos">;</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</pre></div>
<p dir="auto">rustc --version --verbose:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 1.0.0-nightly (f4f10dba2 2015-01-17 20:31:08 +0000)
binary: rustc
commit-hash: f4f10dba2975b51c2d2c92157018db3ac13d4d4a
commit-date: 2015-01-17 20:31:08 +0000
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly"><pre class="notranslate"><code class="notranslate">rustc 1.0.0-nightly (f4f10dba2 2015-01-17 20:31:08 +0000)
binary: rustc
commit-hash: f4f10dba2975b51c2d2c92157018db3ac13d4d4a
commit-date: 2015-01-17 20:31:08 +0000
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly
</code></pre></div>
<p dir="auto">Backtrace: (the offending line 111 is at the bottom of the source snippet below)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="source.rs:111:22: 111:78 error: internal compiler error: aliasability violation with closure
source.rs:111             try_consume( key, &amp;|&amp;: value| item.effects.effects.push( consume( value ) ) );
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box&lt;Any&gt;', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:126

stack backtrace:
   1:         0x69beb95b - sys::backtrace::write::h3574a74d3ac66ba0Dcu
   2:         0x69bff6c3 - rt::unwind::register::hb202fe2a2fd24f5eyYz
   3:         0x69b8363f - rt::unwind::begin_unwind_inner::h24cce2e033842dba7Vz
   4:         0x6f89b58c - diagnostic::SpanHandler::span_bug::he7f492467f6ccae95qF
   5:         0x6f89b543 - diagnostic::SpanHandler::span_bug::he7f492467f6ccae95qF
   6:           0x591d82 - session::Session::span_bug::hbbd1fa2194e20c7cfBp
   7:         0x705e170c - borrowck::move_data::MovePathIndex...std..cmp..PartialEq::ne::h1a3439607cb47b24mTd
   8:         0x705e84bd - borrowck::gather_loans::GatherLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::mutate::hdc7adcebb6b13c04Nsc
   9:         0x705e66c9 - borrowck::gather_loans::GatherLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::borrow::h4842d9e140720d87kqc
  10:         0x705d92f3 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  11:         0x705d5152 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  12:         0x705d8ef6 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  13:         0x705d4d13 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  14:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  15:         0x705d51df - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  16:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  17:         0x705d3b11 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  18:         0x705d3fc7 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  19:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  20:         0x705d3c0a - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  21:         0x705fcc12 - borrowck::check_crate::hb708c27b837bb24bUIe
  22:         0x705f9986 - borrowck::BorrowckCtxt&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_fn::h85e169569b3db6adOHe
  23:         0x705fbb13 - borrowck::check_crate::hb708c27b837bb24bUIe

Could not compile `DotA_Simulator`."><pre class="notranslate"><code class="notranslate">source.rs:111:22: 111:78 error: internal compiler error: aliasability violation with closure
source.rs:111             try_consume( key, &amp;|&amp;: value| item.effects.effects.push( consume( value ) ) );
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box&lt;Any&gt;', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:126

stack backtrace:
   1:         0x69beb95b - sys::backtrace::write::h3574a74d3ac66ba0Dcu
   2:         0x69bff6c3 - rt::unwind::register::hb202fe2a2fd24f5eyYz
   3:         0x69b8363f - rt::unwind::begin_unwind_inner::h24cce2e033842dba7Vz
   4:         0x6f89b58c - diagnostic::SpanHandler::span_bug::he7f492467f6ccae95qF
   5:         0x6f89b543 - diagnostic::SpanHandler::span_bug::he7f492467f6ccae95qF
   6:           0x591d82 - session::Session::span_bug::hbbd1fa2194e20c7cfBp
   7:         0x705e170c - borrowck::move_data::MovePathIndex...std..cmp..PartialEq::ne::h1a3439607cb47b24mTd
   8:         0x705e84bd - borrowck::gather_loans::GatherLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::mutate::hdc7adcebb6b13c04Nsc
   9:         0x705e66c9 - borrowck::gather_loans::GatherLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::borrow::h4842d9e140720d87kqc
  10:         0x705d92f3 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  11:         0x705d5152 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  12:         0x705d8ef6 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  13:         0x705d4d13 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  14:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  15:         0x705d51df - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  16:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  17:         0x705d3b11 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  18:         0x705d3fc7 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  19:         0x705d8c17 - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  20:         0x705d3c0a - borrowck::check_loans::CheckLoanCtxt&lt;'a, 'tcx&gt;.euv..Delegate&lt;'tcx&gt;::decl_without_init::h9c67fbfec08849cbHoa
  21:         0x705fcc12 - borrowck::check_crate::hb708c27b837bb24bUIe
  22:         0x705f9986 - borrowck::BorrowckCtxt&lt;'a, 'tcx&gt;.Visitor&lt;'v&gt;::visit_fn::h85e169569b3db6adOHe
  23:         0x705fbb13 - borrowck::check_crate::hb708c27b837bb24bUIe

Could not compile `DotA_Simulator`.
</code></pre></div>
<p dir="auto">Source code (only the parts related to the problem):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="...
let string = File::open( &amp;Path::new( filename ) ).read_to_string().unwrap();
let json = json::from_str( string.as_slice() ).unwrap();
let object = json.as_object().unwrap();

let mut item = Item::new();
item.name = object[&quot;Name&quot;.to_string()].as_string().unwrap().to_string();
item.cost = object[&quot;ItemCost&quot;.to_string()].as_f64().unwrap();

//get the corresponding f64 to a key
let get_f64 = |&amp;: key: &amp;str| -&gt; f64 {
    object.get( &amp;key.to_string() ).unwrap().as_f64().unwrap()
};

//Checks if all keys are mapped
let contains_all = |&amp;: keys: &amp;[&amp;str]| -&gt; bool {
    for k in keys.iter() {
        if !object.contains_key( &amp;k.to_string() ) { return false; }
    }
    true
};
//Consumes a value if its key exists.
let try_consume = |&amp;: key: &amp;str, consume: &amp;Fn(f64)| {
    match object.get(&amp;key.to_string()) {
        Some(ref json) =&gt; consume( json.as_f64().unwrap() ),
        None =&gt; ()
    };
};
{
//Same as above but consume creates an Effect that gets pushed onto the item.
//This is in a separate scope because the Closure captures item.effects.effects until it goes out of scope.
let try_consume_push = |&amp;: key: &amp;str, consume: &amp;Fn(f64) -&gt; Effect| {
    try_consume( key, &amp;|&amp;: value| item.effects.effects.push( consume( value ) ) );
};
..."><pre class="notranslate"><code class="notranslate">...
let string = File::open( &amp;Path::new( filename ) ).read_to_string().unwrap();
let json = json::from_str( string.as_slice() ).unwrap();
let object = json.as_object().unwrap();

let mut item = Item::new();
item.name = object["Name".to_string()].as_string().unwrap().to_string();
item.cost = object["ItemCost".to_string()].as_f64().unwrap();

//get the corresponding f64 to a key
let get_f64 = |&amp;: key: &amp;str| -&gt; f64 {
    object.get( &amp;key.to_string() ).unwrap().as_f64().unwrap()
};

//Checks if all keys are mapped
let contains_all = |&amp;: keys: &amp;[&amp;str]| -&gt; bool {
    for k in keys.iter() {
        if !object.contains_key( &amp;k.to_string() ) { return false; }
    }
    true
};
//Consumes a value if its key exists.
let try_consume = |&amp;: key: &amp;str, consume: &amp;Fn(f64)| {
    match object.get(&amp;key.to_string()) {
        Some(ref json) =&gt; consume( json.as_f64().unwrap() ),
        None =&gt; ()
    };
};
{
//Same as above but consume creates an Effect that gets pushed onto the item.
//This is in a separate scope because the Closure captures item.effects.effects until it goes out of scope.
let try_consume_push = |&amp;: key: &amp;str, consume: &amp;Fn(f64) -&gt; Effect| {
    try_consume( key, &amp;|&amp;: value| item.effects.effects.push( consume( value ) ) );
};
...
</code></pre></div>
<p dir="auto">If some info about my code matters:<br>
I have a json object from which I want to extract a bunch of values that are all f64 and which get turned into a struct called Effect depending on their key which are put into a struct called Item. To have less duplicate code I define a few helper closures that use the same json object, Item and eachother.<br>
The closures take other closures as arguments which I pass by reference because the compiler complains about them not being sized otherwise.</p>