about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-13 09:06:35 +0000
committerbors <bors@rust-lang.org>2015-01-13 09:06:35 +0000
commitf1241f14dc8f5e708e258a46950e8c7635efe6c7 (patch)
tree66f8df88aef3511994711f65fe55fc7dccedc64c
parent4fc9b41238c5b8d36afd6765c770b6604bf7ef04 (diff)
parentf7745a9be3eb2d9438f08b383156f0a33cbb0cdf (diff)
downloadrust-f1241f14dc8f5e708e258a46950e8c7635efe6c7.tar.gz
rust-f1241f14dc8f5e708e258a46950e8c7635efe6c7.zip
auto merge of #20960 : erickt/rust/fix-associated-types-debuginfo, r=michaelwoerister
Closes #20797
-rw-r--r--src/librustc_trans/trans/debuginfo.rs80
-rw-r--r--src/test/debuginfo/associated_types.rs28
2 files changed, 86 insertions, 22 deletions
diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs
index 2f58baab7fc..5b974d234c0 100644
--- a/src/librustc_trans/trans/debuginfo.rs
+++ b/src/librustc_trans/trans/debuginfo.rs
@@ -323,26 +323,28 @@ impl<'tcx> TypeMap<'tcx> {
     fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                                       type_: Ty<'tcx>) -> UniqueTypeId {
 
-        // basic type           -> {:name of the type:}
-        // tuple                -> {tuple_(:param-uid:)*}
-        // struct               -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
-        // enum                 -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
-        // enum variant         -> {variant_:variant-name:_:enum-uid:}
-        // reference (&)        -> {& :pointee-uid:}
-        // mut reference (&mut) -> {&mut :pointee-uid:}
-        // ptr (*)              -> {* :pointee-uid:}
-        // mut ptr (*mut)       -> {*mut :pointee-uid:}
-        // unique ptr (~)       -> {~ :pointee-uid:}
-        // @-ptr (@)            -> {@ :pointee-uid:}
-        // sized vec ([T; x])   -> {[:size:] :element-uid:}
-        // unsized vec ([T])    -> {[] :element-uid:}
-        // trait (T)            -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
-        // closure              -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
-        //                             :return-type-uid: : (:bounds:)*}
-        // function             -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
-        //                             :return-type-uid:}
-        // unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
-        // gc box               -> {GC_BOX<:pointee-uid:>}
+        // basic type               -> {:name of the type:}
+        // tuple                    -> {tuple_(:param-uid:)*}
+        // struct                   -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
+        // enum                     -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
+        // enum variant             -> {variant_:variant-name:_:enum-uid:}
+        // reference (&)            -> {& :pointee-uid:}
+        // mut reference (&mut)     -> {&mut :pointee-uid:}
+        // ptr (*)                  -> {* :pointee-uid:}
+        // mut ptr (*mut)           -> {*mut :pointee-uid:}
+        // unique ptr (~)           -> {~ :pointee-uid:}
+        // @-ptr (@)                -> {@ :pointee-uid:}
+        // sized vec ([T; x])       -> {[:size:] :element-uid:}
+        // unsized vec ([T])        -> {[] :element-uid:}
+        // trait (T)                -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
+        // closure                  -> {<unsafe_> <once_> :store-sigil:
+        //                                  |(:param-uid:),* <,_...>| -> \
+        //                                  :return-type-uid: : (:bounds:)*}
+        // function                 -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
+        //                                  :return-type-uid:}
+        // unique vec box (~[])     -> {HEAP_VEC_BOX<:pointee-uid:>}
+        // gc box                   -> {GC_BOX<:pointee-uid:>}
+        // projection (<T as U>::V) -> {<:ty-uid: as :trait-uid:> :: :name-uid: }
 
         match self.type_to_unique_id.get(&type_).cloned() {
             Some(unique_type_id) => return unique_type_id,
@@ -435,6 +437,25 @@ impl<'tcx> TypeMap<'tcx> {
                                        principal.substs,
                                        &mut unique_type_id);
             },
+            ty::ty_projection(ref projection) => {
+                unique_type_id.push_str("<");
+
+                let self_ty = projection.trait_ref.self_ty();
+                let self_type_id = self.get_unique_type_id_of_type(cx, self_ty);
+                let self_type_id = self.get_unique_type_id_as_string(self_type_id);
+                unique_type_id.push_str(&self_type_id[]);
+
+                unique_type_id.push_str(" as ");
+
+                from_def_id_and_substs(self,
+                                       cx,
+                                       projection.trait_ref.def_id,
+                                       projection.trait_ref.substs,
+                                       &mut unique_type_id);
+
+                unique_type_id.push_str(">::");
+                unique_type_id.push_str(token::get_name(projection.item_name).get());
+            },
             ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
                 if unsafety == ast::Unsafety::Unsafe {
                     unique_type_id.push_str("unsafe ");
@@ -478,7 +499,10 @@ impl<'tcx> TypeMap<'tcx> {
                                                         closure_ty,
                                                         &mut unique_type_id);
             },
-            _ => {
+            ty::ty_err |
+            ty::ty_infer(_) |
+            ty::ty_open(_) |
+            ty::ty_param(_) => {
                 cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
                                       &ppaux::ty_to_string(cx.tcx(), type_)[],
                                       type_.sty)[])
@@ -3855,10 +3879,22 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_unboxed_closure(..) => {
             output.push_str("closure");
         }
+        ty::ty_projection(ref projection) => {
+            output.push_str("<");
+            let self_ty = projection.trait_ref.self_ty();
+            push_debuginfo_type_name(cx, self_ty, true, output);
+
+            output.push_str(" as ");
+
+            push_item_name(cx, projection.trait_ref.def_id, false, output);
+            push_type_params(cx, projection.trait_ref.substs, output);
+
+            output.push_str(">::");
+            output.push_str(token::get_name(projection.item_name).get());
+        }
         ty::ty_err |
         ty::ty_infer(_) |
         ty::ty_open(_) |
-        ty::ty_projection(..) |
         ty::ty_param(_) => {
             cx.sess().bug(&format!("debuginfo: Trying to create type name for \
                 unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);
diff --git a/src/test/debuginfo/associated_types.rs b/src/test/debuginfo/associated_types.rs
new file mode 100644
index 00000000000..92336e9b34b
--- /dev/null
+++ b/src/test/debuginfo/associated_types.rs
@@ -0,0 +1,28 @@
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-android: FIXME(#10381)
+// min-lldb-version: 310
+
+// compile-flags:-g
+
+struct Peekable<I> where I: Iterator {
+    _iter: I,
+    _next: Option<<I as Iterator>::Item>,
+}
+
+fn main() {
+    let mut iter = Vec::<i32>::new().into_iter();
+    let next = iter.next();
+    let _v = Peekable {
+        _iter: iter,
+        _next : next,
+    };
+}