Skip to content

Commit f1241f1

Browse files
committed
auto merge of #20960 : erickt/rust/fix-associated-types-debuginfo, r=michaelwoerister
Closes #20797
2 parents 4fc9b41 + f7745a9 commit f1241f1

File tree

2 files changed

+86
-22
lines changed

2 files changed

+86
-22
lines changed

src/librustc_trans/trans/debuginfo.rs

+58-22
Original file line numberDiff line numberDiff line change
@@ -323,26 +323,28 @@ impl<'tcx> TypeMap<'tcx> {
323323
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
324324
type_: Ty<'tcx>) -> UniqueTypeId {
325325

326-
// basic type -> {:name of the type:}
327-
// tuple -> {tuple_(:param-uid:)*}
328-
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329-
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330-
// enum variant -> {variant_:variant-name:_:enum-uid:}
331-
// reference (&) -> {& :pointee-uid:}
332-
// mut reference (&mut) -> {&mut :pointee-uid:}
333-
// ptr (*) -> {* :pointee-uid:}
334-
// mut ptr (*mut) -> {*mut :pointee-uid:}
335-
// unique ptr (~) -> {~ :pointee-uid:}
336-
// @-ptr (@) -> {@ :pointee-uid:}
337-
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338-
// unsized vec ([T]) -> {[] :element-uid:}
339-
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340-
// closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
341-
// :return-type-uid: : (:bounds:)*}
342-
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
343-
// :return-type-uid:}
344-
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
345-
// gc box -> {GC_BOX<:pointee-uid:>}
326+
// basic type -> {:name of the type:}
327+
// tuple -> {tuple_(:param-uid:)*}
328+
// struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
329+
// enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
330+
// enum variant -> {variant_:variant-name:_:enum-uid:}
331+
// reference (&) -> {& :pointee-uid:}
332+
// mut reference (&mut) -> {&mut :pointee-uid:}
333+
// ptr (*) -> {* :pointee-uid:}
334+
// mut ptr (*mut) -> {*mut :pointee-uid:}
335+
// unique ptr (~) -> {~ :pointee-uid:}
336+
// @-ptr (@) -> {@ :pointee-uid:}
337+
// sized vec ([T; x]) -> {[:size:] :element-uid:}
338+
// unsized vec ([T]) -> {[] :element-uid:}
339+
// trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
340+
// closure -> {<unsafe_> <once_> :store-sigil:
341+
// |(:param-uid:),* <,_...>| -> \
342+
// :return-type-uid: : (:bounds:)*}
343+
// function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
344+
// :return-type-uid:}
345+
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
346+
// gc box -> {GC_BOX<:pointee-uid:>}
347+
// projection (<T as U>::V) -> {<:ty-uid: as :trait-uid:> :: :name-uid: }
346348

347349
match self.type_to_unique_id.get(&type_).cloned() {
348350
Some(unique_type_id) => return unique_type_id,
@@ -435,6 +437,25 @@ impl<'tcx> TypeMap<'tcx> {
435437
principal.substs,
436438
&mut unique_type_id);
437439
},
440+
ty::ty_projection(ref projection) => {
441+
unique_type_id.push_str("<");
442+
443+
let self_ty = projection.trait_ref.self_ty();
444+
let self_type_id = self.get_unique_type_id_of_type(cx, self_ty);
445+
let self_type_id = self.get_unique_type_id_as_string(self_type_id);
446+
unique_type_id.push_str(&self_type_id[]);
447+
448+
unique_type_id.push_str(" as ");
449+
450+
from_def_id_and_substs(self,
451+
cx,
452+
projection.trait_ref.def_id,
453+
projection.trait_ref.substs,
454+
&mut unique_type_id);
455+
456+
unique_type_id.push_str(">::");
457+
unique_type_id.push_str(token::get_name(projection.item_name).get());
458+
},
438459
ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
439460
if unsafety == ast::Unsafety::Unsafe {
440461
unique_type_id.push_str("unsafe ");
@@ -478,7 +499,10 @@ impl<'tcx> TypeMap<'tcx> {
478499
closure_ty,
479500
&mut unique_type_id);
480501
},
481-
_ => {
502+
ty::ty_err |
503+
ty::ty_infer(_) |
504+
ty::ty_open(_) |
505+
ty::ty_param(_) => {
482506
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
483507
&ppaux::ty_to_string(cx.tcx(), type_)[],
484508
type_.sty)[])
@@ -3855,10 +3879,22 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
38553879
ty::ty_unboxed_closure(..) => {
38563880
output.push_str("closure");
38573881
}
3882+
ty::ty_projection(ref projection) => {
3883+
output.push_str("<");
3884+
let self_ty = projection.trait_ref.self_ty();
3885+
push_debuginfo_type_name(cx, self_ty, true, output);
3886+
3887+
output.push_str(" as ");
3888+
3889+
push_item_name(cx, projection.trait_ref.def_id, false, output);
3890+
push_type_params(cx, projection.trait_ref.substs, output);
3891+
3892+
output.push_str(">::");
3893+
output.push_str(token::get_name(projection.item_name).get());
3894+
}
38583895
ty::ty_err |
38593896
ty::ty_infer(_) |
38603897
ty::ty_open(_) |
3861-
ty::ty_projection(..) |
38623898
ty::ty_param(_) => {
38633899
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
38643900
unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-android: FIXME(#10381)
12+
// min-lldb-version: 310
13+
14+
// compile-flags:-g
15+
16+
struct Peekable<I> where I: Iterator {
17+
_iter: I,
18+
_next: Option<<I as Iterator>::Item>,
19+
}
20+
21+
fn main() {
22+
let mut iter = Vec::<i32>::new().into_iter();
23+
let next = iter.next();
24+
let _v = Peekable {
25+
_iter: iter,
26+
_next : next,
27+
};
28+
}

0 commit comments

Comments
 (0)