@@ -14,7 +14,6 @@ use rustc_middle::bug;
14
14
use rustc_middle:: mir:: interpret:: { ConstAllocation , GlobalAlloc , Scalar } ;
15
15
use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
16
16
use rustc_middle:: ty:: ScalarInt ;
17
- use rustc_span:: symbol:: Symbol ;
18
17
use rustc_target:: abi:: { self , AddressSpace , HasDataLayout , Pointer , Size } ;
19
18
20
19
use libc:: { c_char, c_uint} ;
@@ -181,22 +180,27 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
181
180
unsafe { llvm:: LLVMConstReal ( t, val) }
182
181
}
183
182
184
- fn const_str ( & self , s : Symbol ) -> ( & ' ll Value , & ' ll Value ) {
185
- let s_str = s. as_str ( ) ;
186
- let str_global = * self . const_str_cache . borrow_mut ( ) . entry ( s) . or_insert_with ( || {
187
- let sc = self . const_bytes ( s_str. as_bytes ( ) ) ;
188
- let sym = self . generate_local_symbol_name ( "str" ) ;
189
- let g = self . define_global ( & sym, self . val_ty ( sc) ) . unwrap_or_else ( || {
190
- bug ! ( "symbol `{}` is already defined" , sym) ;
191
- } ) ;
192
- unsafe {
193
- llvm:: LLVMSetInitializer ( g, sc) ;
194
- llvm:: LLVMSetGlobalConstant ( g, True ) ;
195
- llvm:: LLVMRustSetLinkage ( g, llvm:: Linkage :: InternalLinkage ) ;
196
- }
197
- g
198
- } ) ;
199
- let len = s_str. len ( ) ;
183
+ fn const_str ( & self , s : & str ) -> ( & ' ll Value , & ' ll Value ) {
184
+ let str_global = * self
185
+ . const_str_cache
186
+ . borrow_mut ( )
187
+ . raw_entry_mut ( )
188
+ . from_key ( s)
189
+ . or_insert_with ( || {
190
+ let sc = self . const_bytes ( s. as_bytes ( ) ) ;
191
+ let sym = self . generate_local_symbol_name ( "str" ) ;
192
+ let g = self . define_global ( & sym, self . val_ty ( sc) ) . unwrap_or_else ( || {
193
+ bug ! ( "symbol `{}` is already defined" , sym) ;
194
+ } ) ;
195
+ unsafe {
196
+ llvm:: LLVMSetInitializer ( g, sc) ;
197
+ llvm:: LLVMSetGlobalConstant ( g, True ) ;
198
+ llvm:: LLVMRustSetLinkage ( g, llvm:: Linkage :: InternalLinkage ) ;
199
+ }
200
+ ( s. to_owned ( ) , g)
201
+ } )
202
+ . 1 ;
203
+ let len = s. len ( ) ;
200
204
let cs = consts:: ptrcast (
201
205
str_global,
202
206
self . type_ptr_to ( self . layout_of ( self . tcx . types . str_ ) . llvm_type ( self ) ) ,
0 commit comments