@@ -137,16 +137,16 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
137
137
) -> & ' ll Value {
138
138
unsafe {
139
139
let gv = match kind {
140
- Some ( kind) if !& self . tcx . sess . fewer_names ( ) => {
141
- let name = & self . generate_local_symbol_name ( kind) ;
140
+ Some ( kind) if !self . tcx . sess . fewer_names ( ) => {
141
+ let name = self . generate_local_symbol_name ( kind) ;
142
142
let gv = declare:: define_global ( & self , & name[ ..] ,
143
- & self . val_ty ( cv) ) . unwrap_or_else ( ||{
143
+ self . val_ty ( cv) ) . unwrap_or_else ( ||{
144
144
bug ! ( "symbol `{}` is already defined" , name) ;
145
145
} ) ;
146
146
llvm:: LLVMRustSetLinkage ( gv, llvm:: Linkage :: PrivateLinkage ) ;
147
147
gv
148
148
} ,
149
- _ => declare:: define_private_global ( & self , & self . val_ty ( cv) ) ,
149
+ _ => declare:: define_private_global ( & self , self . val_ty ( cv) ) ,
150
150
} ;
151
151
llvm:: LLVMSetInitializer ( gv, cv) ;
152
152
set_global_alignment ( & self , gv, align) ;
@@ -161,7 +161,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
161
161
align : Align ,
162
162
kind : Option < & str > ,
163
163
) -> & ' ll Value {
164
- if let Some ( & gv) = & self . const_globals . borrow ( ) . get ( & cv) {
164
+ if let Some ( & gv) = self . const_globals . borrow ( ) . get ( & cv) {
165
165
unsafe {
166
166
// Upgrade the alignment in cases where the same constant is used with different
167
167
// alignment requirements
@@ -172,21 +172,21 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
172
172
}
173
173
return gv;
174
174
}
175
- let gv = & self . static_addr_of_mut ( cv, align, kind) ;
175
+ let gv = self . static_addr_of_mut ( cv, align, kind) ;
176
176
unsafe {
177
177
llvm:: LLVMSetGlobalConstant ( gv, True ) ;
178
178
}
179
- & self . const_globals . borrow_mut ( ) . insert ( cv, gv) ;
179
+ self . const_globals . borrow_mut ( ) . insert ( cv, gv) ;
180
180
gv
181
181
}
182
182
183
183
fn get_static ( & self , def_id : DefId ) -> & ' ll Value {
184
184
let instance = Instance :: mono ( self . tcx , def_id) ;
185
- if let Some ( & g) = & self . instances . borrow ( ) . get ( & instance) {
185
+ if let Some ( & g) = self . instances . borrow ( ) . get ( & instance) {
186
186
return g;
187
187
}
188
188
189
- let defined_in_current_codegen_unit = & self . codegen_unit
189
+ let defined_in_current_codegen_unit = self . codegen_unit
190
190
. items ( )
191
191
. contains_key ( & MonoItem :: Static ( def_id) ) ;
192
192
assert ! ( !defined_in_current_codegen_unit,
@@ -201,8 +201,8 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
201
201
202
202
let g = if let Some ( id) = self . tcx . hir . as_local_node_id ( def_id) {
203
203
204
- let llty = & self . layout_of ( ty) . llvm_type ( & self ) ;
205
- let ( g, attrs) = match & self . tcx . hir . get ( id) {
204
+ let llty = self . layout_of ( ty) . llvm_type ( & self ) ;
205
+ let ( g, attrs) = match self . tcx . hir . get ( id) {
206
206
Node :: Item ( & hir:: Item {
207
207
ref attrs, span, node : hir:: ItemKind :: Static ( ..) , ..
208
208
} ) => {
@@ -212,7 +212,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
212
212
213
213
let g = declare:: define_global ( & self , & sym[ ..] , llty) . unwrap ( ) ;
214
214
215
- if !& self . tcx . is_reachable_non_generic ( def_id) {
215
+ if !self . tcx . is_reachable_non_generic ( def_id) {
216
216
unsafe {
217
217
llvm:: LLVMRustSetVisibility ( g, llvm:: Visibility :: Hidden ) ;
218
218
}
@@ -224,7 +224,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
224
224
Node :: ForeignItem ( & hir:: ForeignItem {
225
225
ref attrs, span, node : hir:: ForeignItemKind :: Static ( ..) , ..
226
226
} ) => {
227
- let fn_attrs = & self . tcx . codegen_fn_attrs ( def_id) ;
227
+ let fn_attrs = self . tcx . codegen_fn_attrs ( def_id) ;
228
228
( check_and_apply_linkage ( & self , & fn_attrs, ty, sym, Some ( span) ) , attrs)
229
229
}
230
230
@@ -242,9 +242,9 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
242
242
g
243
243
} else {
244
244
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
245
- debug ! ( "get_static: sym={} item_attr={:?}" , sym, & self . tcx. item_attrs( def_id) ) ;
245
+ debug ! ( "get_static: sym={} item_attr={:?}" , sym, self . tcx. item_attrs( def_id) ) ;
246
246
247
- let attrs = & self . tcx . codegen_fn_attrs ( def_id) ;
247
+ let attrs = self . tcx . codegen_fn_attrs ( def_id) ;
248
248
let g = check_and_apply_linkage ( & self , & attrs, ty, sym, None ) ;
249
249
250
250
// Thread-local statics in some other crate need to *always* be linked
@@ -258,11 +258,11 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
258
258
}
259
259
260
260
let needs_dll_storage_attr =
261
- self . use_dll_storage_attrs && !& self . tcx . is_foreign_item ( def_id) &&
261
+ self . use_dll_storage_attrs && !self . tcx . is_foreign_item ( def_id) &&
262
262
// ThinLTO can't handle this workaround in all cases, so we don't
263
263
// emit the attrs. Instead we make them unnecessary by disallowing
264
264
// dynamic linking when cross-language LTO is enabled.
265
- !& self . tcx . sess . opts . debugging_opts . cross_lang_lto . enabled ( ) ;
265
+ !self . tcx . sess . opts . debugging_opts . cross_lang_lto . enabled ( ) ;
266
266
267
267
// If this assertion triggers, there's something wrong with commandline
268
268
// argument validation.
@@ -281,7 +281,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
281
281
// crates, so there are cases where a static with an upstream DefId
282
282
// is actually present in the current crate. We can find out via the
283
283
// is_codegened_item query.
284
- if !& self . tcx . is_codegened_item ( def_id) {
284
+ if !self . tcx . is_codegened_item ( def_id) {
285
285
unsafe {
286
286
llvm:: LLVMSetDLLStorageClass ( g, llvm:: DLLStorageClass :: DllImport ) ;
287
287
}
@@ -297,7 +297,7 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
297
297
}
298
298
}
299
299
300
- & self . instances . borrow_mut ( ) . insert ( instance, g) ;
300
+ self . instances . borrow_mut ( ) . insert ( instance, g) ;
301
301
g
302
302
}
303
303
@@ -307,15 +307,15 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
307
307
is_mutable : bool ,
308
308
) {
309
309
unsafe {
310
- let attrs = & self . tcx . codegen_fn_attrs ( def_id) ;
310
+ let attrs = self . tcx . codegen_fn_attrs ( def_id) ;
311
311
312
312
let ( v, alloc) = match :: mir:: codegen_static_initializer ( & self , def_id) {
313
313
Ok ( v) => v,
314
314
// Error has already been reported
315
315
Err ( _) => return ,
316
316
} ;
317
317
318
- let g = & self . get_static ( def_id) ;
318
+ let g = self . get_static ( def_id) ;
319
319
320
320
// boolean SSA values are i1, but they have to be stored in i8 slots,
321
321
// otherwise some LLVM optimization passes don't work as expected
@@ -344,15 +344,15 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
344
344
let visibility = llvm:: LLVMRustGetVisibility ( g) ;
345
345
346
346
let new_g = llvm:: LLVMRustGetOrInsertGlobal (
347
- & self . llmod , name_string. as_ptr ( ) , val_llty) ;
347
+ self . llmod , name_string. as_ptr ( ) , val_llty) ;
348
348
349
349
llvm:: LLVMRustSetLinkage ( new_g, linkage) ;
350
350
llvm:: LLVMRustSetVisibility ( new_g, visibility) ;
351
351
352
352
// To avoid breaking any invariants, we leave around the old
353
353
// global for the moment; we'll replace all references to it
354
354
// with the new global later. (See base::codegen_backend.)
355
- & self . statics_to_rauw . borrow_mut ( ) . push ( ( g, new_g) ) ;
355
+ self . statics_to_rauw . borrow_mut ( ) . push ( ( g, new_g) ) ;
356
356
new_g
357
357
} ;
358
358
set_global_alignment ( & self , g, self . align_of ( ty) ) ;
@@ -416,19 +416,19 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
416
416
if self . tcx . sess . opts . target_triple . triple ( ) . starts_with ( "wasm32" ) {
417
417
if let Some ( section) = attrs. link_section {
418
418
let section = llvm:: LLVMMDStringInContext (
419
- & self . llcx ,
419
+ self . llcx ,
420
420
section. as_str ( ) . as_ptr ( ) as * const _ ,
421
421
section. as_str ( ) . len ( ) as c_uint ,
422
422
) ;
423
423
let alloc = llvm:: LLVMMDStringInContext (
424
- & self . llcx ,
424
+ self . llcx ,
425
425
alloc. bytes . as_ptr ( ) as * const _ ,
426
426
alloc. bytes . len ( ) as c_uint ,
427
427
) ;
428
428
let data = [ section, alloc] ;
429
- let meta = llvm:: LLVMMDNodeInContext ( & self . llcx , data. as_ptr ( ) , 2 ) ;
429
+ let meta = llvm:: LLVMMDNodeInContext ( self . llcx , data. as_ptr ( ) , 2 ) ;
430
430
llvm:: LLVMAddNamedMetadataOperand (
431
- & self . llmod ,
431
+ self . llmod ,
432
432
"wasm.custom_sections\0 " . as_ptr ( ) as * const _ ,
433
433
meta,
434
434
) ;
@@ -439,8 +439,8 @@ impl StaticMethods<'tcx> for CodegenCx<'ll, 'tcx> {
439
439
440
440
if attrs. flags . contains ( CodegenFnAttrFlags :: USED ) {
441
441
// This static will be stored in the llvm.used variable which is an array of i8*
442
- let cast = llvm:: LLVMConstPointerCast ( g, & self . type_i8p ( ) ) ;
443
- & self . used_statics . borrow_mut ( ) . push ( cast) ;
442
+ let cast = llvm:: LLVMConstPointerCast ( g, self . type_i8p ( ) ) ;
443
+ self . used_statics . borrow_mut ( ) . push ( cast) ;
444
444
}
445
445
}
446
446
}
0 commit comments