@@ -23,7 +23,6 @@ use rustc_middle::ty::{self, AdtDef, ExistentialProjection, Ty, TyCtxt};
23
23
use rustc_target:: abi:: { Integer , TagEncoding , Variants } ;
24
24
use smallvec:: SmallVec ;
25
25
26
- use std:: cell:: RefCell ;
27
26
use std:: fmt:: Write ;
28
27
29
28
// Compute the name of the type as it should be stored in debuginfo. Does not do
@@ -34,13 +33,16 @@ pub fn compute_debuginfo_type_name<'tcx>(
34
33
tcx : TyCtxt < ' tcx > ,
35
34
t : Ty < ' tcx > ,
36
35
qualified : bool ,
37
- type_name_cache : & RefCell < FxHashMap < ( Ty < ' tcx > , bool ) , String > > ,
36
+ type_name_cache : & mut FxHashMap < ( Ty < ' tcx > , bool ) , String > ,
38
37
) -> String {
39
38
let _prof = tcx. prof . generic_activity ( "compute_debuginfo_type_name" ) ;
40
39
41
40
let mut result = String :: with_capacity ( 64 ) ;
42
41
let mut visited = FxHashSet :: default ( ) ;
43
42
push_debuginfo_type_name ( tcx, t, qualified, & mut result, & mut visited, type_name_cache) ;
43
+ if type_name_cache. insert ( ( t, qualified) , result. clone ( ) ) . is_some ( ) {
44
+ bug ! ( "type name is already in the type name cache!" ) ;
45
+ }
44
46
result
45
47
}
46
48
@@ -52,11 +54,11 @@ fn push_debuginfo_type_name<'tcx>(
52
54
qualified : bool ,
53
55
output : & mut String ,
54
56
visited : & mut FxHashSet < Ty < ' tcx > > ,
55
- type_name_cache : & RefCell < FxHashMap < ( Ty < ' tcx > , bool ) , String > > ,
57
+ type_name_cache : & mut FxHashMap < ( Ty < ' tcx > , bool ) , String > ,
56
58
) {
57
59
// Check if we have seen this type and qualifier before.
58
- if let Some ( type_name) = type_name_cache. borrow ( ) . get ( & ( & t, qualified) ) {
59
- output. push_str ( & type_name. clone ( ) ) ;
60
+ if let Some ( type_name) = type_name_cache. get ( & ( t, qualified) ) {
61
+ output. push_str ( & type_name[ .. ] ) ;
60
62
return ;
61
63
}
62
64
@@ -424,10 +426,6 @@ fn push_debuginfo_type_name<'tcx>(
424
426
}
425
427
}
426
428
427
- if type_name_cache. borrow_mut ( ) . insert ( ( & t, qualified) , output. clone ( ) ) . is_some ( ) {
428
- bug ! ( "type name is already in the type name cache!" ) ;
429
- }
430
-
431
429
/// MSVC names enums differently than other platforms so that the debugging visualization
432
430
// format (natvis) is able to understand enums and render the active variant correctly in the
433
431
// debugger. For more information, look in `src/etc/natvis/intrinsic.natvis` and
@@ -439,7 +437,7 @@ fn push_debuginfo_type_name<'tcx>(
439
437
substs : SubstsRef < ' tcx > ,
440
438
output : & mut String ,
441
439
visited : & mut FxHashSet < Ty < ' tcx > > ,
442
- type_name_cache : & RefCell < FxHashMap < ( Ty < ' tcx > , bool ) , String > > ,
440
+ type_name_cache : & mut FxHashMap < ( Ty < ' tcx > , bool ) , String > ,
443
441
) {
444
442
let layout = tcx. layout_of ( tcx. param_env ( def. did ) . and ( ty) ) . expect ( "layout error" ) ;
445
443
@@ -557,7 +555,7 @@ fn push_generic_params_internal<'tcx>(
557
555
substs : SubstsRef < ' tcx > ,
558
556
output : & mut String ,
559
557
visited : & mut FxHashSet < Ty < ' tcx > > ,
560
- type_name_cache : & RefCell < FxHashMap < ( Ty < ' tcx > , bool ) , String > > ,
558
+ type_name_cache : & mut FxHashMap < ( Ty < ' tcx > , bool ) , String > ,
561
559
) -> bool {
562
560
if substs. non_erasable_generics ( ) . next ( ) . is_none ( ) {
563
561
return false ;
@@ -644,7 +642,7 @@ pub fn push_generic_params<'tcx>(
644
642
tcx : TyCtxt < ' tcx > ,
645
643
substs : SubstsRef < ' tcx > ,
646
644
output : & mut String ,
647
- type_name_cache : & RefCell < FxHashMap < ( Ty < ' tcx > , bool ) , String > > ,
645
+ type_name_cache : & mut FxHashMap < ( Ty < ' tcx > , bool ) , String > ,
648
646
) {
649
647
let _prof = tcx. prof . generic_activity ( "compute_debuginfo_type_name" ) ;
650
648
let mut visited = FxHashSet :: default ( ) ;
0 commit comments