33
44use std:: borrow:: Cow ;
55use std:: cell:: RefCell ;
6- use std:: collections:: HashMap ;
76use std:: num:: NonZeroU64 ;
87use std:: rc:: Rc ;
98
109use rand:: rngs:: StdRng ;
1110
11+ use rustc_data_structures:: fx:: FxHashMap ;
1212use rustc:: mir;
1313use rustc:: ty:: {
1414 self ,
1515 layout:: { LayoutOf , Size } ,
1616 Ty ,
1717} ;
1818use rustc_ast:: attr;
19- use rustc_span:: { source_map:: Span , symbol:: sym} ;
19+ use rustc_span:: { source_map:: Span , symbol:: { sym, Symbol } } ;
2020
2121use crate :: * ;
2222
@@ -75,7 +75,7 @@ pub struct MemoryExtra {
7575 pub intptrcast : intptrcast:: MemoryExtra ,
7676
7777 /// Mapping extern static names to their canonical allocation.
78- pub ( crate ) extern_statics : HashMap < & ' static str , AllocId > ,
78+ pub ( crate ) extern_statics : FxHashMap < Symbol , AllocId > ,
7979
8080 /// The random number generator used for resolving non-determinism.
8181 /// Needs to be queried by ptr_to_int, hence needs interior mutability.
@@ -92,7 +92,7 @@ impl MemoryExtra {
9292 MemoryExtra {
9393 stacked_borrows,
9494 intptrcast : Default :: default ( ) ,
95- extern_statics : HashMap :: default ( ) ,
95+ extern_statics : FxHashMap :: default ( ) ,
9696 rng : RefCell :: new ( rng) ,
9797 }
9898 }
@@ -111,7 +111,7 @@ impl MemoryExtra {
111111 this. memory
112112 . extra
113113 . extern_statics
114- . insert ( "__cxa_thread_atexit_impl" , place. ptr . assert_ptr ( ) . alloc_id )
114+ . insert ( Symbol :: intern ( "__cxa_thread_atexit_impl" ) , place. ptr . assert_ptr ( ) . alloc_id )
115115 . unwrap_none ( ) ;
116116 }
117117 _ => { } // No "extern statics" supported on this platform
@@ -310,11 +310,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
310310 } ;
311311 let attrs = tcx. get_attrs ( def_id) ;
312312 let link_name = match attr:: first_attr_value_str_by_name ( & attrs, sym:: link_name) {
313- Some ( name) => name. as_str ( ) ,
314- None => tcx. item_name ( def_id) . as_str ( ) ,
313+ Some ( name) => name,
314+ None => tcx. item_name ( def_id) ,
315315 } ;
316316 // Check if we know this one.
317- if let Some ( canonical_id) = mem. extra . extern_statics . get ( & * link_name) {
317+ if let Some ( canonical_id) = mem. extra . extern_statics . get ( & link_name) {
318318 trace ! ( "canonical_alloc_id: {:?} ({}) -> {:?}" , id, link_name, canonical_id) ;
319319 * canonical_id
320320 } else {
0 commit comments