@@ -44,7 +44,6 @@ use std::ffi::CString;
44
44
use std:: fmt:: Write ;
45
45
use std:: path:: Path ;
46
46
use std:: ptr;
47
- use std:: rc:: Rc ;
48
47
use syntax:: ast;
49
48
use syntax:: symbol:: { Interner , InternedString } ;
50
49
use syntax_pos:: { self , Span } ;
@@ -116,9 +115,8 @@ impl<'tcx> TypeMap<'tcx> {
116
115
unique_type_id : UniqueTypeId ,
117
116
metadata : DIType ) {
118
117
if self . unique_id_to_metadata . insert ( unique_type_id, metadata) . is_some ( ) {
119
- let unique_type_id_str = self . get_unique_type_id_as_string ( unique_type_id) ;
120
118
bug ! ( "Type metadata for unique id '{}' is already in the TypeMap!" ,
121
- & unique_type_id_str [ .. ] ) ;
119
+ self . get_unique_type_id_as_string ( unique_type_id ) ) ;
122
120
}
123
121
}
124
122
@@ -132,7 +130,7 @@ impl<'tcx> TypeMap<'tcx> {
132
130
133
131
// Get the string representation of a UniqueTypeId. This method will fail if
134
132
// the id is unknown.
135
- fn get_unique_type_id_as_string ( & self , unique_type_id : UniqueTypeId ) -> Rc < str > {
133
+ fn get_unique_type_id_as_string ( & self , unique_type_id : UniqueTypeId ) -> & str {
136
134
let UniqueTypeId ( interner_key) = unique_type_id;
137
135
self . unique_id_interner . get ( interner_key)
138
136
}
@@ -181,7 +179,7 @@ impl<'tcx> TypeMap<'tcx> {
181
179
-> UniqueTypeId {
182
180
let enum_type_id = self . get_unique_type_id_of_type ( cx, enum_type) ;
183
181
let enum_variant_type_id = format ! ( "{}::{}" ,
184
- & self . get_unique_type_id_as_string( enum_type_id) ,
182
+ self . get_unique_type_id_as_string( enum_type_id) ,
185
183
variant_name) ;
186
184
let interner_key = self . unique_id_interner . intern ( & enum_variant_type_id) ;
187
185
UniqueTypeId ( interner_key)
@@ -622,29 +620,25 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
622
620
let metadata_for_uid = match type_map. find_metadata_for_unique_id ( unique_type_id) {
623
621
Some ( metadata) => metadata,
624
622
None => {
625
- let unique_type_id_str =
626
- type_map. get_unique_type_id_as_string ( unique_type_id) ;
627
623
span_bug ! ( usage_site_span,
628
624
"Expected type metadata for unique \
629
625
type id '{}' to already be in \
630
626
the debuginfo::TypeMap but it \
631
627
was not. (Ty = {})",
632
- & unique_type_id_str [ .. ] ,
628
+ type_map . get_unique_type_id_as_string ( unique_type_id ) ,
633
629
t) ;
634
630
}
635
631
} ;
636
632
637
633
match type_map. find_metadata_for_type ( t) {
638
634
Some ( metadata) => {
639
635
if metadata != metadata_for_uid {
640
- let unique_type_id_str =
641
- type_map. get_unique_type_id_as_string ( unique_type_id) ;
642
636
span_bug ! ( usage_site_span,
643
637
"Mismatch between Ty and \
644
638
UniqueTypeId maps in \
645
639
debuginfo::TypeMap. \
646
640
UniqueTypeId={}, Ty={}",
647
- & unique_type_id_str [ .. ] ,
641
+ type_map . get_unique_type_id_as_string ( unique_type_id ) ,
648
642
t) ;
649
643
}
650
644
}
@@ -1525,13 +1519,10 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1525
1519
let enum_llvm_type = type_of:: type_of ( cx, enum_type) ;
1526
1520
let ( enum_type_size, enum_type_align) = size_and_align_of ( cx, enum_llvm_type) ;
1527
1521
1528
- let unique_type_id_str = debug_context ( cx)
1529
- . type_map
1530
- . borrow ( )
1531
- . get_unique_type_id_as_string ( unique_type_id) ;
1532
-
1533
1522
let enum_name = CString :: new ( enum_name) . unwrap ( ) ;
1534
- let unique_type_id_str = CString :: new ( unique_type_id_str. as_bytes ( ) ) . unwrap ( ) ;
1523
+ let unique_type_id_str = CString :: new (
1524
+ debug_context ( cx) . type_map . borrow ( ) . get_unique_type_id_as_string ( unique_type_id) . as_bytes ( )
1525
+ ) . unwrap ( ) ;
1535
1526
let enum_metadata = unsafe {
1536
1527
llvm:: LLVMRustDIBuilderCreateUnionType (
1537
1528
DIB ( cx) ,
@@ -1668,11 +1659,10 @@ fn create_struct_stub(cx: &CrateContext,
1668
1659
-> DICompositeType {
1669
1660
let ( struct_size, struct_align) = size_and_align_of ( cx, struct_llvm_type) ;
1670
1661
1671
- let unique_type_id_str = debug_context ( cx) . type_map
1672
- . borrow ( )
1673
- . get_unique_type_id_as_string ( unique_type_id) ;
1674
1662
let name = CString :: new ( struct_type_name) . unwrap ( ) ;
1675
- let unique_type_id = CString :: new ( unique_type_id_str. as_bytes ( ) ) . unwrap ( ) ;
1663
+ let unique_type_id = CString :: new (
1664
+ debug_context ( cx) . type_map . borrow ( ) . get_unique_type_id_as_string ( unique_type_id) . as_bytes ( )
1665
+ ) . unwrap ( ) ;
1676
1666
let metadata_stub = unsafe {
1677
1667
// LLVMRustDIBuilderCreateStructType() wants an empty array. A null
1678
1668
// pointer will lead to hard to trace and debug LLVM assertions
@@ -1706,11 +1696,10 @@ fn create_union_stub(cx: &CrateContext,
1706
1696
-> DICompositeType {
1707
1697
let ( union_size, union_align) = size_and_align_of ( cx, union_llvm_type) ;
1708
1698
1709
- let unique_type_id_str = debug_context ( cx) . type_map
1710
- . borrow ( )
1711
- . get_unique_type_id_as_string ( unique_type_id) ;
1712
1699
let name = CString :: new ( union_type_name) . unwrap ( ) ;
1713
- let unique_type_id = CString :: new ( unique_type_id_str. as_bytes ( ) ) . unwrap ( ) ;
1700
+ let unique_type_id = CString :: new (
1701
+ debug_context ( cx) . type_map . borrow ( ) . get_unique_type_id_as_string ( unique_type_id) . as_bytes ( )
1702
+ ) . unwrap ( ) ;
1714
1703
let metadata_stub = unsafe {
1715
1704
// LLVMRustDIBuilderCreateUnionType() wants an empty array. A null
1716
1705
// pointer will lead to hard to trace and debug LLVM assertions
0 commit comments