<p dir="auto">Hi<br>
I am currently writing a pretty simple implementation of a binary tree and appear to have stumbled upon an internal compiler error that only occurs when compiling with the debugInfo (-g) flag  the compiler insisted i report it. :)<br>
p.s. I am running under windows 7 on a 32 bit machine</p>
<p dir="auto">heres the compiler output</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="task 'rustc' failed at 'Box&lt;Any&gt;', C:\bot\slave\nightly-win\build\src\libsyntax\diagnostic.rs:162


2.rs:19     let tree = Branch(20,box Branch(5,box Leaf(2),box Leaf(9)),box Branch(40, box Leaf(35),box Null));
                    ^~~~
hello2.rs:46:1: 53:2 warning: code is never used: `areListsEqual`, #[warn(dead_code)] on by default
hello2.rs:46 fn areListsEqual&lt;T: PartialEq&gt;(xs: &amp;List&lt;T&gt;, ys: &amp;List&lt;T&gt;) -&gt; bool{
hello2.rs:47    match (xs,ys) {
hello2.rs:48        (&amp;Nil,&amp;Nil) =&gt; true,
hello2.rs:49        (&amp;Cons(ref x,box ref nextXs),&amp;Cons(ref y,box ref nextYs)) if x == y =&gt; 
hello2.rs:50            areListsEqual(nextXs,nextYs),
hello2.rs:51        _ =&gt; false
             ...
hello2.rs:46:1: 53:2 warning: function `areListsEqual` should have a snake case name such as `are_lists_equal`, #[warn(non_snake_case_functions)] on by default
hello2.rs:46 fn areListsEqual&lt;T: PartialEq&gt;(xs: &amp;List&lt;T&gt;, ys: &amp;List&lt;T&gt;) -&gt; bool{
hello2.rs:47    match (xs,ys) {
hello2.rs:48        (&amp;Nil,&amp;Nil) =&gt; true,
hello2.rs:49        (&amp;Cons(ref x,box ref nextXs),&amp;Cons(ref y,box ref nextYs)) if x == y =&gt; 
hello2.rs:50            areListsEqual(nextXs,nextYs),
hello2.rs:51        _ =&gt; false
             ...
hello2.rs:55:1: 57:2 warning: code is never used: `prependList`, #[warn(dead_code)] on by default
hello2.rs:55 fn prependList&lt;T&gt; (xs: List&lt;T&gt;, v: T) -&gt; List&lt;T&gt;{
hello2.rs:56    Cons(v, box xs)
hello2.rs:57 }
hello2.rs:55:1: 57:2 warning: function `prependList` should have a snake case name such as `prepend_list`, #[warn(non_snake_case_functions)] on by default
hello2.rs:55 fn prependList&lt;T&gt; (xs: List&lt;T&gt;, v: T) -&gt; List&lt;T&gt;{
hello2.rs:56    Cons(v, box xs)
hello2.rs:57 }
hello2.rs:59:1: 61:2 warning: code is never used: `scaleVector`, #[warn(dead_code)] on by default
hello2.rs:59 fn scaleVector(scale: int,xs: Vec&lt;int&gt;) -&gt; Vec&lt;int&gt; {
hello2.rs:60    xs.move_iter().map(|i| i + scale).collect()
hello2.rs:61 }
hello2.rs:59:1: 61:2 warning: function `scaleVector` should have a snake case name such as `scale_vector`, #[warn(non_snake_case_functions)] on by default
hello2.rs:59 fn scaleVector(scale: int,xs: Vec&lt;int&gt;) -&gt; Vec&lt;int&gt; {
hello2.rs:60    xs.move_iter().map(|i| i + scale).collect()
hello2.rs:61 }
hello2.rs:63:1: 85:2 warning: function `createBinarySearchTree` should have a snake case name such as `create_binary_search_tree`, #[warn(non_snake_case_functions)] on by default
hello2.rs:63 fn createBinarySearchTree(vector : Vec&lt;int&gt;) -&gt; BinaryTree&lt;int&gt;{
hello2.rs:64    
hello2.rs:65    fn placeNode(val: int, btree: &amp;mut BinaryTree&lt;int&gt;) -&gt; BinaryTree&lt;int&gt; {
hello2.rs:66        match btree {
hello2.rs:67            &amp;Leaf(tval) if val &gt; tval =&gt; Branch(tval,box Null,box Leaf(val)),   
hello2.rs:68            &amp;Leaf(tval) if val &lt; tval =&gt; Branch(tval,box Leaf(val),box Null),
             ...
hello2.rs:69:21: 69:29 warning: unused variable: `left`, #[warn(unused_variable)] on by default
hello2.rs:69            &amp;Branch(tval,box ref left,box ref mut right) if val &gt; tval =&gt; placeNode(val,right)  ,
                                         ^~~~~~~~
hello2.rs:70:38: 70:47 warning: unused variable: `right`, #[warn(unused_variable)] on by default
hello2.rs:70            &amp;Branch(tval,box ref mut left,box ref right) if val &lt; tval =&gt; placeNode(val,left),
                                                          ^~~~~~~~~
hello2.rs:73:21: 73:29 warning: unused variable: `left`, #[warn(unused_variable)] on by default
hello2.rs:73            &amp;Branch(lval,box ref left,box ref right) if val == lval =&gt; fail!(&quot;already has a node with {}&quot;,lval),
                                         ^~~~~~~~
hello2.rs:73:34: 73:43 warning: unused variable: `right`, #[warn(unused_variable)] on by default
hello2.rs:73            &amp;Branch(lval,box ref left,box ref right) if val == lval =&gt; fail!(&quot;already has a node with {}&quot;,lval),
                                                      ^~~~~~~~~
hello2.rs:65:2: 76:3 warning: function `placeNode` should have a snake case name such as `place_node`, #[warn(non_snake_case_functions)] on by default
hello2.rs:65    fn placeNode(val: int, btree: &amp;mut BinaryTree&lt;int&gt;) -&gt; BinaryTree&lt;int&gt; {
hello2.rs:66        match btree {
hello2.rs:67            &amp;Leaf(tval) if val &gt; tval =&gt; Branch(tval,box Null,box Leaf(val)),   
hello2.rs:68            &amp;Leaf(tval) if val &lt; tval =&gt; Branch(tval,box Leaf(val),box Null),
hello2.rs:69            &amp;Branch(tval,box ref left,box ref mut right) if val &gt; tval =&gt; placeNode(val,right)  ,
hello2.rs:70            &amp;Branch(tval,box ref mut left,box ref right) if val &lt; tval =&gt; placeNode(val,left),
             ...
hello2.rs:87:1: 101:2 warning: function `printTree` should have a snake case name such as `print_tree`, #[warn(non_snake_case_functions)] on by default
hello2.rs:87 fn printTree(tree : &amp;BinaryTree&lt;int&gt;){
hello2.rs:88    fn innerPrint(foreword : &amp;str,tree : &amp;BinaryTree&lt;int&gt;, level : int) {
hello2.rs:89        let lvDesc = format!(&quot;lv {}&quot;,level);
hello2.rs:90        match tree{
hello2.rs:91            &amp;Leaf(val) =&gt; println!(&quot;{}-{} leaf: {}&quot;,lvDesc,foreword,val),
hello2.rs:92            &amp;Branch(val,box ref left, box ref right) =&gt; {
             ...
hello2.rs:88:2: 99:3 warning: function `innerPrint` should have a snake case name such as `inner_print`, #[warn(non_snake_case_functions)] on by default
hello2.rs:88    fn innerPrint(foreword : &amp;str,tree : &amp;BinaryTree&lt;int&gt;, level : int) {
hello2.rs:89        let lvDesc = format!(&quot;lv {}&quot;,level);
hello2.rs:90        match tree{
hello2.rs:91            &amp;Leaf(val) =&gt; println!(&quot;{}-{} leaf: {}&quot;,lvDesc,foreword,val),
hello2.rs:92            &amp;Branch(val,box ref left, box ref right) =&gt; {
hello2.rs:93                println!(&quot;{}-{} node: {}&quot;,lvDesc,foreword,val);
             ...
hello2.rs:103:1: 107:2 warning: code is never used: `displayVector`, #[warn(dead_code)] on by default
hello2.rs:103 fn displayVector(vector: Vec&lt;int&gt;){
hello2.rs:104   for v in vector.iter() {
hello2.rs:105       println!(&quot;{}&quot;,v)
hello2.rs:106   }
hello2.rs:107 }
hello2.rs:103:1: 107:2 warning: function `displayVector` should have a snake case name such as `display_vector`, #[warn(non_snake_case_functions)] on by default
hello2.rs:103 fn displayVector(vector: Vec&lt;int&gt;){
hello2.rs:104   for v in vector.iter() {
hello2.rs:105       println!(&quot;{}&quot;,v)
hello2.rs:106   }
hello2.rs:107 }
hello2.rs:109:1: 117:2 warning: code is never used: `displayList`, #[warn(dead_code)] on by default
hello2.rs:109 fn displayList&lt;int&gt; (xs: &amp;List&lt;int&gt;){
hello2.rs:110   match xs{
hello2.rs:111       &amp;Cons(v,box ref rest) =&gt; {
hello2.rs:112           println!(&quot;{}&quot;,v);
hello2.rs:113           displayList::&lt;int&gt;(rest)
hello2.rs:114       },
              ...
hello2.rs:109:1: 117:2 warning: function `displayList` should have a snake case name such as `display_list`, #[warn(non_snake_case_functions)] on by default
hello2.rs:109 fn displayList&lt;int&gt; (xs: &amp;List&lt;int&gt;){
hello2.rs:110   match xs{
hello2.rs:111       &amp;Cons(v,box ref rest) =&gt; {
hello2.rs:112           println!(&quot;{}&quot;,v);
hello2.rs:113           displayList::&lt;int&gt;(rest)
hello2.rs:114       },
              ...
error: internal compiler error: Type metadata for unique id '{&amp;{&amp;[]{struct d517309cb671f9ac/2157e}}}' is already in the TypeMap!
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"><pre class="notranslate"><code class="notranslate">task 'rustc' failed at 'Box&lt;Any&gt;', C:\bot\slave\nightly-win\build\src\libsyntax\diagnostic.rs:162


2.rs:19     let tree = Branch(20,box Branch(5,box Leaf(2),box Leaf(9)),box Branch(40, box Leaf(35),box Null));
                    ^~~~
hello2.rs:46:1: 53:2 warning: code is never used: `areListsEqual`, #[warn(dead_code)] on by default
hello2.rs:46 fn areListsEqual&lt;T: PartialEq&gt;(xs: &amp;List&lt;T&gt;, ys: &amp;List&lt;T&gt;) -&gt; bool{
hello2.rs:47    match (xs,ys) {
hello2.rs:48        (&amp;Nil,&amp;Nil) =&gt; true,
hello2.rs:49        (&amp;Cons(ref x,box ref nextXs),&amp;Cons(ref y,box ref nextYs)) if x == y =&gt; 
hello2.rs:50            areListsEqual(nextXs,nextYs),
hello2.rs:51        _ =&gt; false
             ...
hello2.rs:46:1: 53:2 warning: function `areListsEqual` should have a snake case name such as `are_lists_equal`, #[warn(non_snake_case_functions)] on by default
hello2.rs:46 fn areListsEqual&lt;T: PartialEq&gt;(xs: &amp;List&lt;T&gt;, ys: &amp;List&lt;T&gt;) -&gt; bool{
hello2.rs:47    match (xs,ys) {
hello2.rs:48        (&amp;Nil,&amp;Nil) =&gt; true,
hello2.rs:49        (&amp;Cons(ref x,box ref nextXs),&amp;Cons(ref y,box ref nextYs)) if x == y =&gt; 
hello2.rs:50            areListsEqual(nextXs,nextYs),
hello2.rs:51        _ =&gt; false
             ...
hello2.rs:55:1: 57:2 warning: code is never used: `prependList`, #[warn(dead_code)] on by default
hello2.rs:55 fn prependList&lt;T&gt; (xs: List&lt;T&gt;, v: T) -&gt; List&lt;T&gt;{
hello2.rs:56    Cons(v, box xs)
hello2.rs:57 }
hello2.rs:55:1: 57:2 warning: function `prependList` should have a snake case name such as `prepend_list`, #[warn(non_snake_case_functions)] on by default
hello2.rs:55 fn prependList&lt;T&gt; (xs: List&lt;T&gt;, v: T) -&gt; List&lt;T&gt;{
hello2.rs:56    Cons(v, box xs)
hello2.rs:57 }
hello2.rs:59:1: 61:2 warning: code is never used: `scaleVector`, #[warn(dead_code)] on by default
hello2.rs:59 fn scaleVector(scale: int,xs: Vec&lt;int&gt;) -&gt; Vec&lt;int&gt; {
hello2.rs:60    xs.move_iter().map(|i| i + scale).collect()
hello2.rs:61 }
hello2.rs:59:1: 61:2 warning: function `scaleVector` should have a snake case name such as `scale_vector`, #[warn(non_snake_case_functions)] on by default
hello2.rs:59 fn scaleVector(scale: int,xs: Vec&lt;int&gt;) -&gt; Vec&lt;int&gt; {
hello2.rs:60    xs.move_iter().map(|i| i + scale).collect()
hello2.rs:61 }
hello2.rs:63:1: 85:2 warning: function `createBinarySearchTree` should have a snake case name such as `create_binary_search_tree`, #[warn(non_snake_case_functions)] on by default
hello2.rs:63 fn createBinarySearchTree(vector : Vec&lt;int&gt;) -&gt; BinaryTree&lt;int&gt;{
hello2.rs:64    
hello2.rs:65    fn placeNode(val: int, btree: &amp;mut BinaryTree&lt;int&gt;) -&gt; BinaryTree&lt;int&gt; {
hello2.rs:66        match btree {
hello2.rs:67            &amp;Leaf(tval) if val &gt; tval =&gt; Branch(tval,box Null,box Leaf(val)),   
hello2.rs:68            &amp;Leaf(tval) if val &lt; tval =&gt; Branch(tval,box Leaf(val),box Null),
             ...
hello2.rs:69:21: 69:29 warning: unused variable: `left`, #[warn(unused_variable)] on by default
hello2.rs:69            &amp;Branch(tval,box ref left,box ref mut right) if val &gt; tval =&gt; placeNode(val,right)  ,
                                         ^~~~~~~~
hello2.rs:70:38: 70:47 warning: unused variable: `right`, #[warn(unused_variable)] on by default
hello2.rs:70            &amp;Branch(tval,box ref mut left,box ref right) if val &lt; tval =&gt; placeNode(val,left),
                                                          ^~~~~~~~~
hello2.rs:73:21: 73:29 warning: unused variable: `left`, #[warn(unused_variable)] on by default
hello2.rs:73            &amp;Branch(lval,box ref left,box ref right) if val == lval =&gt; fail!("already has a node with {}",lval),
                                         ^~~~~~~~
hello2.rs:73:34: 73:43 warning: unused variable: `right`, #[warn(unused_variable)] on by default
hello2.rs:73            &amp;Branch(lval,box ref left,box ref right) if val == lval =&gt; fail!("already has a node with {}",lval),
                                                      ^~~~~~~~~
hello2.rs:65:2: 76:3 warning: function `placeNode` should have a snake case name such as `place_node`, #[warn(non_snake_case_functions)] on by default
hello2.rs:65    fn placeNode(val: int, btree: &amp;mut BinaryTree&lt;int&gt;) -&gt; BinaryTree&lt;int&gt; {
hello2.rs:66        match btree {
hello2.rs:67            &amp;Leaf(tval) if val &gt; tval =&gt; Branch(tval,box Null,box Leaf(val)),   
hello2.rs:68            &amp;Leaf(tval) if val &lt; tval =&gt; Branch(tval,box Leaf(val),box Null),
hello2.rs:69            &amp;Branch(tval,box ref left,box ref mut right) if val &gt; tval =&gt; placeNode(val,right)  ,
hello2.rs:70            &amp;Branch(tval,box ref mut left,box ref right) if val &lt; tval =&gt; placeNode(val,left),
             ...
hello2.rs:87:1: 101:2 warning: function `printTree` should have a snake case name such as `print_tree`, #[warn(non_snake_case_functions)] on by default
hello2.rs:87 fn printTree(tree : &amp;BinaryTree&lt;int&gt;){
hello2.rs:88    fn innerPrint(foreword : &amp;str,tree : &amp;BinaryTree&lt;int&gt;, level : int) {
hello2.rs:89        let lvDesc = format!("lv {}",level);
hello2.rs:90        match tree{
hello2.rs:91            &amp;Leaf(val) =&gt; println!("{}-{} leaf: {}",lvDesc,foreword,val),
hello2.rs:92            &amp;Branch(val,box ref left, box ref right) =&gt; {
             ...
hello2.rs:88:2: 99:3 warning: function `innerPrint` should have a snake case name such as `inner_print`, #[warn(non_snake_case_functions)] on by default
hello2.rs:88    fn innerPrint(foreword : &amp;str,tree : &amp;BinaryTree&lt;int&gt;, level : int) {
hello2.rs:89        let lvDesc = format!("lv {}",level);
hello2.rs:90        match tree{
hello2.rs:91            &amp;Leaf(val) =&gt; println!("{}-{} leaf: {}",lvDesc,foreword,val),
hello2.rs:92            &amp;Branch(val,box ref left, box ref right) =&gt; {
hello2.rs:93                println!("{}-{} node: {}",lvDesc,foreword,val);
             ...
hello2.rs:103:1: 107:2 warning: code is never used: `displayVector`, #[warn(dead_code)] on by default
hello2.rs:103 fn displayVector(vector: Vec&lt;int&gt;){
hello2.rs:104   for v in vector.iter() {
hello2.rs:105       println!("{}",v)
hello2.rs:106   }
hello2.rs:107 }
hello2.rs:103:1: 107:2 warning: function `displayVector` should have a snake case name such as `display_vector`, #[warn(non_snake_case_functions)] on by default
hello2.rs:103 fn displayVector(vector: Vec&lt;int&gt;){
hello2.rs:104   for v in vector.iter() {
hello2.rs:105       println!("{}",v)
hello2.rs:106   }
hello2.rs:107 }
hello2.rs:109:1: 117:2 warning: code is never used: `displayList`, #[warn(dead_code)] on by default
hello2.rs:109 fn displayList&lt;int&gt; (xs: &amp;List&lt;int&gt;){
hello2.rs:110   match xs{
hello2.rs:111       &amp;Cons(v,box ref rest) =&gt; {
hello2.rs:112           println!("{}",v);
hello2.rs:113           displayList::&lt;int&gt;(rest)
hello2.rs:114       },
              ...
hello2.rs:109:1: 117:2 warning: function `displayList` should have a snake case name such as `display_list`, #[warn(non_snake_case_functions)] on by default
hello2.rs:109 fn displayList&lt;int&gt; (xs: &amp;List&lt;int&gt;){
hello2.rs:110   match xs{
hello2.rs:111       &amp;Cons(v,box ref rest) =&gt; {
hello2.rs:112           println!("{}",v);
hello2.rs:113           displayList::&lt;int&gt;(rest)
hello2.rs:114       },
              ...
error: internal compiler error: Type metadata for unique id '{&amp;{&amp;[]{struct d517309cb671f9ac/2157e}}}' is already in the TypeMap!
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
</code></pre></div>
<p dir="auto">Compiling libcore with -g leads to the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: internal compiler error: Type metadata for ty::t '&amp;[core::fmt::rt::Piece&lt;&gt;]' is already in the TypeMap!"><pre class="notranslate"><code class="notranslate">error: internal compiler error: Type metadata for ty::t '&amp;[core::fmt::rt::Piece&lt;&gt;]' is already in the TypeMap!
</code></pre></div>
<p dir="auto">This is due to the vec slice in question occurring multiple times along a type reference chain and the code path for vec slices doesn't take that possibility into account. This is also a potential problem for other kinds of types, e.g. fixed length vector types or function types. For regular pointer types this is already handled correctly.</p>