<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#![feature(default_type_params)]

pub struct Foo&lt;Bar = Bar&gt;;

pub struct Baz(Foo);

fn main() {}"><pre class="notranslate"><span class="pl-c1">#!<span class="pl-kos">[</span>feature<span class="pl-kos">(</span>default_type_params<span class="pl-kos">)</span><span class="pl-kos">]</span></span>

<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">Foo</span><span class="pl-kos">&lt;</span><span class="pl-smi">Bar</span> = <span class="pl-smi">Bar</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>

<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">Baz</span><span class="pl-kos">(</span><span class="pl-smi">Foo</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-kos">}</span></pre></div>
<hr>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ RUST_BACKTRACE=1 rustc foo.rs
foo.rs:5:16: 5:19 error: internal compiler error: Type parameter `Bar` (Bar/TypeSpace/0) out of range when substituting (root type=Bar)
foo.rs:5 pub struct Baz(Foo);
                        ^~~
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 'Box&lt;Any&gt;', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:113

stack backtrace:
   1:        0x10c01dda9 - rt::backtrace::imp::write::h189e19957ab9c695OLq
   2:        0x10c021077 - failure::on_fail::h03dc2437e5a88345n2q
   3:        0x10c28e395 - unwind::begin_unwind_inner::hf0bc25e3a9312068Jud
   4:        0x10b782267 - unwind::begin_unwind::h13550917712925122129
   5:        0x10b782200 - unwind::begin_unwind::h13550917712925122129
   6:        0x108ef3651 - middle::subst::SubstFolder&lt;'a, 'tcx&gt;.TypeFolder&lt;'tcx&gt;::fold_ty::h51d3eabd2d589326k7U
   7:        0x1092dd867 - middle::typeck::astconv::ast_path_substs::h17230674362159792950
   8:        0x1092f274a - middle::typeck::astconv::ast_path_to_ty::h9293039141781755470
   9:        0x1092da6ad - middle::typeck::astconv::ast_ty_to_ty::h10119988251165278301
  10:        0x10932b4c5 - middle::typeck::collect::convert_field::h2da86f9ee62891ddJBf
  11:        0x1092f574a - middle::typeck::collect::convert_struct::h2b7ee55df10ef64egtg
  12:        0x1092d0f9d - middle::typeck::collect::convert::h31420af36e1b2433Pgg
  13:        0x1092cae53 - middle::typeck::collect::collect_item_types::h500e21302badea5eGhf
  14:        0x108c47b96 - util::common::time::h17347838844167099674
  15:        0x109486e18 - middle::typeck::check_crate::h4a8150eb203da20bLVk
  16:        0x1094f1d6f - driver::driver::phase_3_run_analysis_passes::hb45292d67f60c7dbEvx
  17:        0x1094ebfb3 - driver::driver::compile_input::hcfe10250ad7929a4qcx
  18:        0x109572834 - driver::run_compiler::h3e10e2d15988f082J0A
  19:        0x109570966 - driver::run::closure.147488
  20:        0x108c612eb - task::TaskBuilder&lt;S&gt;::try_future::closure.101597
  21:        0x108c611d3 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.101568
  22:        0x108be379d - task::spawn_opts::closure.8528
  23:        0x10c2f595c - rust_try_inner
  24:        0x10c2f5946 - rust_try
  25:        0x10c28ba07 - unwind::try::h538ab1bff32c8080rjd
  26:        0x10c28b88c - task::Task::run::h756ab4c75afdd7bdCzc
  27:        0x108be35c2 - task::spawn_opts::closure.8467
  28:        0x10c28d24a - thread::thread_start::hf25b5002f28406f0NTc
  29:     0x7fff9469c899 - _pthread_body
  30:     0x7fff9469c72a - _pthread_struct_init"><pre class="notranslate">$ <span class="pl-s1">RUST_BACKTRACE=1 rustc foo.rs</span>
<span class="pl-c1">foo.rs:5:16: 5:19 error: internal compiler error: Type parameter `Bar` (Bar/TypeSpace/0) out of range when substituting (root type=Bar)</span>
<span class="pl-c1">foo.rs:5 pub struct Baz(Foo);</span>
<span class="pl-c1">                        ^~~</span>
<span class="pl-c1">note: the compiler hit an unexpected failure path. this is a bug.</span>
<span class="pl-c1">note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html</span>
<span class="pl-c1">note: run with `RUST_BACKTRACE=1` for a backtrace</span>
<span class="pl-c1">task 'rustc' failed at 'Box&lt;Any&gt;', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:113</span>

<span class="pl-c1">stack backtrace:</span>
<span class="pl-c1">   1:        0x10c01dda9 - rt::backtrace::imp::write::h189e19957ab9c695OLq</span>
<span class="pl-c1">   2:        0x10c021077 - failure::on_fail::h03dc2437e5a88345n2q</span>
<span class="pl-c1">   3:        0x10c28e395 - unwind::begin_unwind_inner::hf0bc25e3a9312068Jud</span>
<span class="pl-c1">   4:        0x10b782267 - unwind::begin_unwind::h13550917712925122129</span>
<span class="pl-c1">   5:        0x10b782200 - unwind::begin_unwind::h13550917712925122129</span>
<span class="pl-c1">   6:        0x108ef3651 - middle::subst::SubstFolder&lt;'a, 'tcx&gt;.TypeFolder&lt;'tcx&gt;::fold_ty::h51d3eabd2d589326k7U</span>
<span class="pl-c1">   7:        0x1092dd867 - middle::typeck::astconv::ast_path_substs::h17230674362159792950</span>
<span class="pl-c1">   8:        0x1092f274a - middle::typeck::astconv::ast_path_to_ty::h9293039141781755470</span>
<span class="pl-c1">   9:        0x1092da6ad - middle::typeck::astconv::ast_ty_to_ty::h10119988251165278301</span>
<span class="pl-c1">  10:        0x10932b4c5 - middle::typeck::collect::convert_field::h2da86f9ee62891ddJBf</span>
<span class="pl-c1">  11:        0x1092f574a - middle::typeck::collect::convert_struct::h2b7ee55df10ef64egtg</span>
<span class="pl-c1">  12:        0x1092d0f9d - middle::typeck::collect::convert::h31420af36e1b2433Pgg</span>
<span class="pl-c1">  13:        0x1092cae53 - middle::typeck::collect::collect_item_types::h500e21302badea5eGhf</span>
<span class="pl-c1">  14:        0x108c47b96 - util::common::time::h17347838844167099674</span>
<span class="pl-c1">  15:        0x109486e18 - middle::typeck::check_crate::h4a8150eb203da20bLVk</span>
<span class="pl-c1">  16:        0x1094f1d6f - driver::driver::phase_3_run_analysis_passes::hb45292d67f60c7dbEvx</span>
<span class="pl-c1">  17:        0x1094ebfb3 - driver::driver::compile_input::hcfe10250ad7929a4qcx</span>
<span class="pl-c1">  18:        0x109572834 - driver::run_compiler::h3e10e2d15988f082J0A</span>
<span class="pl-c1">  19:        0x109570966 - driver::run::closure.147488</span>
<span class="pl-c1">  20:        0x108c612eb - task::TaskBuilder&lt;S&gt;::try_future::closure.101597</span>
<span class="pl-c1">  21:        0x108c611d3 - task::TaskBuilder&lt;S&gt;::spawn_internal::closure.101568</span>
<span class="pl-c1">  22:        0x108be379d - task::spawn_opts::closure.8528</span>
<span class="pl-c1">  23:        0x10c2f595c - rust_try_inner</span>
<span class="pl-c1">  24:        0x10c2f5946 - rust_try</span>
<span class="pl-c1">  25:        0x10c28ba07 - unwind::try::h538ab1bff32c8080rjd</span>
<span class="pl-c1">  26:        0x10c28b88c - task::Task::run::h756ab4c75afdd7bdCzc</span>
<span class="pl-c1">  27:        0x108be35c2 - task::spawn_opts::closure.8467</span>
<span class="pl-c1">  28:        0x10c28d24a - thread::thread_start::hf25b5002f28406f0NTc</span>
<span class="pl-c1">  29:     0x7fff9469c899 - _pthread_body</span>
<span class="pl-c1">  30:     0x7fff9469c72a - _pthread_struct_init</span></pre></div>
<p dir="auto">This example causes an ICE:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#![feature(default_type_params)]

trait Foo&lt;T=Self&gt; {
    fn method(&amp;self);
}

fn foo(x: &amp;Foo) { }

fn main() { }"><pre class="notranslate"><code class="notranslate">#![feature(default_type_params)]

trait Foo&lt;T=Self&gt; {
    fn method(&amp;self);
}

fn foo(x: &amp;Foo) { }

fn main() { }
</code></pre></div>
<p dir="auto">yields</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:7:12: 7:15 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Self) substs=Substs[types=[[];[];[];[]], regions=[[];[];[];[]]]"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:7:12: 7:15 error: internal compiler error: Type parameter `Self/SelfSpace.0` (Self/SelfSpace/0) out of range when substituting (root type=Self) substs=Substs[types=[[];[];[];[]], regions=[[];[];[];[]]]
</code></pre></div>
<p dir="auto">This is because, in an object type, the self parameter slot is empty, so the substitution of the default fails. I'm not 100% sure what's the best way to fix this. We could make the substitution report a proper error rather than ICE; perhaps that's best.</p>
<p dir="auto">It is debatable whether such a trait ought to be object safe, but it seems harmless, if pointless, since the <code class="notranslate">Self</code> type winds up being revealed.</p>