<p dir="auto">I'm in Arch Linux x86_64</p>
<p dir="auto">This is the repository and branch where the bug in question happened: <a href="https://github.com/Denommus/xpath-rs/tree/rust-bug">https://github.com/Denommus/xpath-rs/tree/rust-bug</a></p>
<p dir="auto">After some study, I found out the smallest code that causes the issue:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="use std::kinds::marker::ContravariantLifetime;

struct Foo&lt;'a&gt; {
    foo: *const int,
    lf: ContravariantLifetime&lt;'a&gt;
}

impl&lt;'a&gt; Drop for Foo&lt;'a&gt; {
    fn drop(&amp;mut self) {
    }
}"><pre class="notranslate"><span class="pl-k">use</span> std<span class="pl-kos">::</span>kinds<span class="pl-kos">::</span>marker<span class="pl-kos">::</span><span class="pl-v">ContravariantLifetime</span><span class="pl-kos">;</span>

<span class="pl-k">struct</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c1">foo</span><span class="pl-kos">:</span> <span class="pl-c1">*</span><span class="pl-k">const</span> <span class="pl-smi">int</span><span class="pl-kos">,</span>
    <span class="pl-c1">lf</span><span class="pl-kos">:</span> <span class="pl-smi">ContravariantLifetime</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Drop</span> <span class="pl-k">for</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">drop</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-kos">{</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">When trying to <code class="notranslate">cargo build</code> or <code class="notranslate">cargo test</code> it, I get the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   Compiling xpath v0.1.0 (file:/home/yuri/Projetos/PistonDevelopers/xpath-rs)
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /build/rust-git/src/rust/src/librustc/middle/subst.rs:405

stack backtrace:
   1:     0x7fd280653440 - rt::backtrace::imp::write::hd9494d95b8843aac9Mp
   2:     0x7fd280656ca0 - &lt;unknown&gt;
   3:     0x7fd280e11660 - unwind::begin_unwind_inner::h86c91288dccdf7edcZd
   4:     0x7fd280e112b0 - unwind::begin_unwind_fmt::h1cb579d85bd16aefFWd
   5:     0x7fd280e11270 - rust_begin_unwind
   6:     0x7fd280e4cde0 - failure::begin_unwind::h4bcdf2c748255fc2srj
   7:     0x7fd280e50670 - failure::fail_bounds_check::hdab871e57fe12ae2Epj
   8:     0x7fd281564060 - &lt;unknown&gt;
   9:     0x7fd281564020 - &lt;unknown&gt;
  10:     0x7fd281562b30 - &lt;unknown&gt;
  11:     0x7fd281562960 - &lt;unknown&gt;
  12:     0x7fd28150af40 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_ty::h13798902dd9366ecRMU
  13:     0x7fd28150ae50 - &lt;unknown&gt;
  14:     0x7fd281685fd0 - middle::ty::lookup_field_type::h45aac711c7fa1076qeS
  15:     0x7fd281547e60 - middle::ty::struct_fields::hb5d9b2dc874148eeHmS
  16:     0x7fd2816b10e0 - &lt;unknown&gt;
  17:     0x7fd28164e5d0 - middle::ty::type_contents::hc7f87097be3796b7AsP
  18:     0x7fd2819fa0d0 - &lt;unknown&gt;
  19:     0x7fd2819fcfc0 - middle::kind::check_crate::h567230afc53cc6d1sxQ
  20:     0x7fd281d2da50 - driver::driver::phase_3_run_analysis_passes::h6dd6f772dd74de516Eq
  21:     0x7fd281d28eb0 - driver::driver::compile_input::h74d2c1dd617400e9Mrq
  22:     0x7fd281ddf670 - &lt;unknown&gt;
  23:     0x7fd281ddf580 - &lt;unknown&gt;
  24:     0x7fd281df2dd0 - &lt;unknown&gt;
  25:     0x7fd281df2b60 - &lt;unknown&gt;
  26:     0x7fd283e0ff80 - &lt;unknown&gt;
  27:     0x7fd280e60dc0 - rust_try
  28:     0x7fd280e0e6e0 - unwind::try::h62bccd25ee1c5a2dBNd
  29:     0x7fd280e0e440 - task::Task::run::h899cbe26c861f39cXYc
  30:     0x7fd283e0fd70 - &lt;unknown&gt;
  31:     0x7fd280e106c0 - &lt;unknown&gt;
  32:     0x7fd2800da060 - start_thread
  33:     0x7fd280ad9489 - __clone
  34:                0x0 - &lt;unknown&gt;

Could not execute process `rustc src/lib.rs --crate-name xpath --crate-type lib -g --test --out-dir /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test/deps` (status=101)"><pre class="notranslate"><code class="notranslate">   Compiling xpath v0.1.0 (file:/home/yuri/Projetos/PistonDevelopers/xpath-rs)
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /build/rust-git/src/rust/src/librustc/middle/subst.rs:405

stack backtrace:
   1:     0x7fd280653440 - rt::backtrace::imp::write::hd9494d95b8843aac9Mp
   2:     0x7fd280656ca0 - &lt;unknown&gt;
   3:     0x7fd280e11660 - unwind::begin_unwind_inner::h86c91288dccdf7edcZd
   4:     0x7fd280e112b0 - unwind::begin_unwind_fmt::h1cb579d85bd16aefFWd
   5:     0x7fd280e11270 - rust_begin_unwind
   6:     0x7fd280e4cde0 - failure::begin_unwind::h4bcdf2c748255fc2srj
   7:     0x7fd280e50670 - failure::fail_bounds_check::hdab871e57fe12ae2Epj
   8:     0x7fd281564060 - &lt;unknown&gt;
   9:     0x7fd281564020 - &lt;unknown&gt;
  10:     0x7fd281562b30 - &lt;unknown&gt;
  11:     0x7fd281562960 - &lt;unknown&gt;
  12:     0x7fd28150af40 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_ty::h13798902dd9366ecRMU
  13:     0x7fd28150ae50 - &lt;unknown&gt;
  14:     0x7fd281685fd0 - middle::ty::lookup_field_type::h45aac711c7fa1076qeS
  15:     0x7fd281547e60 - middle::ty::struct_fields::hb5d9b2dc874148eeHmS
  16:     0x7fd2816b10e0 - &lt;unknown&gt;
  17:     0x7fd28164e5d0 - middle::ty::type_contents::hc7f87097be3796b7AsP
  18:     0x7fd2819fa0d0 - &lt;unknown&gt;
  19:     0x7fd2819fcfc0 - middle::kind::check_crate::h567230afc53cc6d1sxQ
  20:     0x7fd281d2da50 - driver::driver::phase_3_run_analysis_passes::h6dd6f772dd74de516Eq
  21:     0x7fd281d28eb0 - driver::driver::compile_input::h74d2c1dd617400e9Mrq
  22:     0x7fd281ddf670 - &lt;unknown&gt;
  23:     0x7fd281ddf580 - &lt;unknown&gt;
  24:     0x7fd281df2dd0 - &lt;unknown&gt;
  25:     0x7fd281df2b60 - &lt;unknown&gt;
  26:     0x7fd283e0ff80 - &lt;unknown&gt;
  27:     0x7fd280e60dc0 - rust_try
  28:     0x7fd280e0e6e0 - unwind::try::h62bccd25ee1c5a2dBNd
  29:     0x7fd280e0e440 - task::Task::run::h899cbe26c861f39cXYc
  30:     0x7fd283e0fd70 - &lt;unknown&gt;
  31:     0x7fd280e106c0 - &lt;unknown&gt;
  32:     0x7fd2800da060 - start_thread
  33:     0x7fd280ad9489 - __clone
  34:                0x0 - &lt;unknown&gt;

Could not execute process `rustc src/lib.rs --crate-name xpath --crate-type lib -g --test --out-dir /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test -L /home/yuri/Projetos/PistonDevelopers/xpath-rs/target/test/deps` (status=101)
</code></pre></div>
<p dir="auto">Compiling <a href="https://gist.github.com/bgamari/d3e3a7a6b83c1bfaa00e/a6833426eb941d47232d305a86571b0962ce554c">this program</a> results in the following error with rustc <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/00cdd639a93ec1dcad85cebc52214eeba0441c93/hovercard" href="https://github.com/rust-lang/rust/commit/00cdd639a93ec1dcad85cebc52214eeba0441c93"><tt>00cdd63</tt></a>,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ RUST_LOG=rustc::middle::kind,rustc::middle::typeck::astconv RUST_BACKTRACE=1 /opt/exp/rust/x86_64-unknown-linux-gnu/stage1/bin/rustc crash.rs
InterDEBUG:rustc::middle::typeck::astconv: ast_region_to_region(lifetime='a id=8) yields ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: opt_ast_region_to_region(opt_lifetime=Some('a)) yields ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: ty_rptr r=ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: mk_pointer(ptr_ty=RPtr(ReEarlyBound(12u32, TypeSpace, 0u, syntax::ast::Name(58u32))))
DEBUG:rustc::middle::typeck::astconv: ast_region_to_region(lifetime='a id=18) yields ReEarlyBound(14, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: ty_of_method_or_bare_fn
DEBUG:rustc::middle::typeck::astconv: opt_ast_region_to_region(opt_lifetime=None) yields ReLateBound(19, BrAnon(0))
DEBUG:rustc::middle::typeck::astconv: ty_of_method_or_bare_fn
DEBUG:rustc::middle::kind: checking impl with self type ty_struct(DefId { krate: 0, node: 5 }, Substs { types: VecPerParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }, regions: NonerasedRegions(VecPerParamSpace {TypeSpace: [ReEarlyBound(14, TypeSpace, 0, Name(58))], SelfSpace: [], FnSpace: [], }) })
crash.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='au32)
crash.rs:1 use std::ty::Unsafe;

task 'rustc' failed at 'Box&lt;Any&gt;', /opt/exp/rust/src/libsyntax/diagnostic.rs:107

stack backtrace:
   1:     0x7fc9e8922840 - rt::backtrace::imp::write::h0a20b0836877d9ac0Mp::v0.11.0
   2:     0x7fc9e89260a0 - failure::on_fail::h9368950ceb08d6a5f8p::v0.11.0
   3:     0x7fc9e90f7eb0 - unwind::begin_unwind_inner::h1ea00938b93c7417cZd::v0.11.0
   4:     0x7fc9e75bf9a0 - unwind::begin_unwind::h12621653176727986714::v0.11.0
   5:     0x7fc9e75bf8d0 - diagnostic::SpanHandler::span_bug::h4bae981243ffc58eMac::v0.11.0
   6:     0x7fc9e990c470 - driver::session::Session::span_bug::hc179e601dc679fecYos::v0.11.0
   7:     0x7fc9e991d800 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_region::he5ebd51cee9a84b33rV::v0.11.0
   8:     0x7fc9e98c4270 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_ty::h59e6cfaf115bff0ahuV::v0.11.0
   9:     0x7fc9e98c4180 - middle::subst::T.Subst::subst_spanned::h16361762956049246516::v0.11.0
  10:     0x7fc9e9a45830 - middle::ty::lookup_field_type::h3e7b27996e88cd1bHMS::v0.11.0
  11:     0x7fc9e9901c90 - middle::ty::struct_fields::h729f0dbbcf21bf37YUS::v0.11.0
  12:     0x7fc9e9a71fd0 - middle::ty::type_contents::tc_ty::h7d685e11e712e8a6V1P::v0.11.0
  13:     0x7fc9e9a0a250 - middle::ty::type_contents::h8e510766cec98181R0P::v0.11.0
  14:     0x7fc9e9dbefd0 - middle::kind::check_item::hfa5461b803c6c40dwpR::v0.11.0
  15:     0x7fc9e9dc1ed0 - middle::kind::check_crate::h70941b58fca9fc5bVfR::v0.11.0
  16:     0x7fc9ea0edfd0 - driver::driver::phase_3_run_analysis_passes::hd94ede6fcda9089cznr::v0.11.0
  17:     0x7fc9ea0e9750 - driver::driver::compile_input::h22443fcf4e1357eafar::v0.11.0
  18:     0x7fc9ea1a0140 - driver::run_compiler::hd0a576aeaeea68b3W0t::v0.11.0
  19:     0x7fc9ea1a0050 - driver::main_args::closure.127086
  20:     0x7fc9ea1b4560 - task::TaskBuilder&lt;S&gt;::try_future::closure.128230
  21:     0x7fc9ea1b4230 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.128207
  22:     0x7fc9ec193d00 - task::spawn_opts::closure.7759
  23:     0x7fc9e9252e60 - rust_try
  24:     0x7fc9e90f4490 - unwind::try::hb071379e55686597BNd::v0.11.0
  25:     0x7fc9e90f4190 - task::Task::run::ha6ba4f51b8a2758dXYc::v0.11.0
  26:     0x7fc9ec193ac0 - task::spawn_opts::closure.7705
  27:     0x7fc9e90f6ce0 - thread::thread_start::hc20479a5894ce695vld::v0.11.0
  28:     0x7fc9e83a40c0 - start_thread
  29:     0x7fc9e8dbb2d9 - __clone
  30:                0x0 - &lt;unknown&gt;"><pre class="notranslate"><code class="notranslate">$ RUST_LOG=rustc::middle::kind,rustc::middle::typeck::astconv RUST_BACKTRACE=1 /opt/exp/rust/x86_64-unknown-linux-gnu/stage1/bin/rustc crash.rs
InterDEBUG:rustc::middle::typeck::astconv: ast_region_to_region(lifetime='a id=8) yields ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: opt_ast_region_to_region(opt_lifetime=Some('a)) yields ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: ty_rptr r=ReEarlyBound(12, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: mk_pointer(ptr_ty=RPtr(ReEarlyBound(12u32, TypeSpace, 0u, syntax::ast::Name(58u32))))
DEBUG:rustc::middle::typeck::astconv: ast_region_to_region(lifetime='a id=18) yields ReEarlyBound(14, TypeSpace, 0, 'a)
DEBUG:rustc::middle::typeck::astconv: ty_of_method_or_bare_fn
DEBUG:rustc::middle::typeck::astconv: opt_ast_region_to_region(opt_lifetime=None) yields ReLateBound(19, BrAnon(0))
DEBUG:rustc::middle::typeck::astconv: ty_of_method_or_bare_fn
DEBUG:rustc::middle::kind: checking impl with self type ty_struct(DefId { krate: 0, node: 5 }, Substs { types: VecPerParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }, regions: NonerasedRegions(VecPerParamSpace {TypeSpace: [ReEarlyBound(14, TypeSpace, 0, Name(58))], SelfSpace: [], FnSpace: [], }) })
crash.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='au32)
crash.rs:1 use std::ty::Unsafe;

task 'rustc' failed at 'Box&lt;Any&gt;', /opt/exp/rust/src/libsyntax/diagnostic.rs:107

stack backtrace:
   1:     0x7fc9e8922840 - rt::backtrace::imp::write::h0a20b0836877d9ac0Mp::v0.11.0
   2:     0x7fc9e89260a0 - failure::on_fail::h9368950ceb08d6a5f8p::v0.11.0
   3:     0x7fc9e90f7eb0 - unwind::begin_unwind_inner::h1ea00938b93c7417cZd::v0.11.0
   4:     0x7fc9e75bf9a0 - unwind::begin_unwind::h12621653176727986714::v0.11.0
   5:     0x7fc9e75bf8d0 - diagnostic::SpanHandler::span_bug::h4bae981243ffc58eMac::v0.11.0
   6:     0x7fc9e990c470 - driver::session::Session::span_bug::hc179e601dc679fecYos::v0.11.0
   7:     0x7fc9e991d800 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_region::he5ebd51cee9a84b33rV::v0.11.0
   8:     0x7fc9e98c4270 - middle::subst::SubstFolder&lt;'a&gt;.TypeFolder::fold_ty::h59e6cfaf115bff0ahuV::v0.11.0
   9:     0x7fc9e98c4180 - middle::subst::T.Subst::subst_spanned::h16361762956049246516::v0.11.0
  10:     0x7fc9e9a45830 - middle::ty::lookup_field_type::h3e7b27996e88cd1bHMS::v0.11.0
  11:     0x7fc9e9901c90 - middle::ty::struct_fields::h729f0dbbcf21bf37YUS::v0.11.0
  12:     0x7fc9e9a71fd0 - middle::ty::type_contents::tc_ty::h7d685e11e712e8a6V1P::v0.11.0
  13:     0x7fc9e9a0a250 - middle::ty::type_contents::h8e510766cec98181R0P::v0.11.0
  14:     0x7fc9e9dbefd0 - middle::kind::check_item::hfa5461b803c6c40dwpR::v0.11.0
  15:     0x7fc9e9dc1ed0 - middle::kind::check_crate::h70941b58fca9fc5bVfR::v0.11.0
  16:     0x7fc9ea0edfd0 - driver::driver::phase_3_run_analysis_passes::hd94ede6fcda9089cznr::v0.11.0
  17:     0x7fc9ea0e9750 - driver::driver::compile_input::h22443fcf4e1357eafar::v0.11.0
  18:     0x7fc9ea1a0140 - driver::run_compiler::hd0a576aeaeea68b3W0t::v0.11.0
  19:     0x7fc9ea1a0050 - driver::main_args::closure.127086
  20:     0x7fc9ea1b4560 - task::TaskBuilder&lt;S&gt;::try_future::closure.128230
  21:     0x7fc9ea1b4230 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.128207
  22:     0x7fc9ec193d00 - task::spawn_opts::closure.7759
  23:     0x7fc9e9252e60 - rust_try
  24:     0x7fc9e90f4490 - unwind::try::hb071379e55686597BNd::v0.11.0
  25:     0x7fc9e90f4190 - task::Task::run::ha6ba4f51b8a2758dXYc::v0.11.0
  26:     0x7fc9ec193ac0 - task::spawn_opts::closure.7705
  27:     0x7fc9e90f6ce0 - thread::thread_start::hc20479a5894ce695vld::v0.11.0
  28:     0x7fc9e83a40c0 - start_thread
  29:     0x7fc9e8dbb2d9 - __clone
  30:                0x0 - &lt;unknown&gt;
</code></pre></div>