@@ -397,7 +397,7 @@ fn collect_items_rec<'tcx>(
397
397
let instance = Instance :: mono ( tcx, def_id) ;
398
398
399
399
// Sanity check whether this ended up being collected accidentally
400
- debug_assert ! ( should_codegen_locally( tcx, & instance) ) ;
400
+ debug_assert ! ( should_codegen_locally( tcx, instance) ) ;
401
401
402
402
let DefKind :: Static { nested, .. } = tcx. def_kind ( def_id) else { bug ! ( ) } ;
403
403
// Nested statics have no type.
@@ -429,7 +429,7 @@ fn collect_items_rec<'tcx>(
429
429
}
430
430
MonoItem :: Fn ( instance) => {
431
431
// Sanity check whether this ended up being collected accidentally
432
- debug_assert ! ( should_codegen_locally( tcx, & instance) ) ;
432
+ debug_assert ! ( should_codegen_locally( tcx, instance) ) ;
433
433
434
434
// Keep track of the monomorphization recursion depth
435
435
recursion_depth_reset = Some ( check_recursion_limit (
@@ -474,7 +474,7 @@ fn collect_items_rec<'tcx>(
474
474
}
475
475
hir:: InlineAsmOperand :: SymStatic { path : _, def_id } => {
476
476
let instance = Instance :: mono ( tcx, * def_id) ;
477
- if should_codegen_locally ( tcx, & instance) {
477
+ if should_codegen_locally ( tcx, instance) {
478
478
trace ! ( "collecting static {:?}" , def_id) ;
479
479
used_items. push ( dummy_spanned ( MonoItem :: Static ( * def_id) ) ) ;
480
480
}
@@ -557,7 +557,7 @@ fn collect_items_rec<'tcx>(
557
557
/// If the type name is longer than before+after, it will be written to a file.
558
558
fn shrunk_instance_name < ' tcx > (
559
559
tcx : TyCtxt < ' tcx > ,
560
- instance : & Instance < ' tcx > ,
560
+ instance : Instance < ' tcx > ,
561
561
) -> ( String , Option < PathBuf > ) {
562
562
let s = instance. to_string ( ) ;
563
563
@@ -603,7 +603,7 @@ fn check_recursion_limit<'tcx>(
603
603
if !recursion_limit. value_within_limit ( adjusted_recursion_depth) {
604
604
let def_span = tcx. def_span ( def_id) ;
605
605
let def_path_str = tcx. def_path_str ( def_id) ;
606
- let ( shrunk, written_to_path) = shrunk_instance_name ( tcx, & instance) ;
606
+ let ( shrunk, written_to_path) = shrunk_instance_name ( tcx, instance) ;
607
607
let mut path = PathBuf :: new ( ) ;
608
608
let was_written = if let Some ( written_to_path) = written_to_path {
609
609
path = written_to_path;
@@ -645,7 +645,7 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
645
645
//
646
646
// Bail out in these cases to avoid that bad user experience.
647
647
if !tcx. type_length_limit ( ) . value_within_limit ( type_length) {
648
- let ( shrunk, written_to_path) = shrunk_instance_name ( tcx, & instance) ;
648
+ let ( shrunk, written_to_path) = shrunk_instance_name ( tcx, instance) ;
649
649
let span = tcx. def_span ( instance. def_id ( ) ) ;
650
650
let mut path = PathBuf :: new ( ) ;
651
651
let was_written = if let Some ( path2) = written_to_path {
@@ -892,7 +892,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
892
892
if let ty:: Closure ( def_id, args) = * source_ty. kind ( ) {
893
893
let instance =
894
894
Instance :: resolve_closure ( self . tcx , def_id, args, ty:: ClosureKind :: FnOnce ) ;
895
- if should_codegen_locally ( self . tcx , & instance) {
895
+ if should_codegen_locally ( self . tcx , instance) {
896
896
self . used_items . push ( create_fn_mono_item ( self . tcx , instance, span) ) ;
897
897
}
898
898
} else {
@@ -902,7 +902,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
902
902
mir:: Rvalue :: ThreadLocalRef ( def_id) => {
903
903
assert ! ( self . tcx. is_thread_local_static( def_id) ) ;
904
904
let instance = Instance :: mono ( self . tcx , def_id) ;
905
- if should_codegen_locally ( self . tcx , & instance) {
905
+ if should_codegen_locally ( self . tcx , instance) {
906
906
trace ! ( "collecting thread-local static {:?}" , def_id) ;
907
907
self . used_items . push ( respan ( span, MonoItem :: Static ( def_id) ) ) ;
908
908
}
@@ -929,7 +929,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
929
929
let tcx = self . tcx ;
930
930
let push_mono_lang_item = |this : & mut Self , lang_item : LangItem | {
931
931
let instance = Instance :: mono ( tcx, tcx. require_lang_item ( lang_item, Some ( source) ) ) ;
932
- if should_codegen_locally ( tcx, & instance) {
932
+ if should_codegen_locally ( tcx, instance) {
933
933
this. used_items . push ( create_fn_mono_item ( tcx, instance, source) ) ;
934
934
}
935
935
} ;
@@ -962,7 +962,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
962
962
}
963
963
mir:: InlineAsmOperand :: SymStatic { def_id } => {
964
964
let instance = Instance :: mono ( self . tcx , def_id) ;
965
- if should_codegen_locally ( self . tcx , & instance) {
965
+ if should_codegen_locally ( self . tcx , instance) {
966
966
trace ! ( "collecting asm sym static {:?}" , def_id) ;
967
967
self . used_items . push ( respan ( source, MonoItem :: Static ( def_id) ) ) ;
968
968
}
@@ -1051,7 +1051,7 @@ fn visit_instance_use<'tcx>(
1051
1051
output : & mut MonoItems < ' tcx > ,
1052
1052
) {
1053
1053
debug ! ( "visit_item_use({:?}, is_direct_call={:?})" , instance, is_direct_call) ;
1054
- if !should_codegen_locally ( tcx, & instance) {
1054
+ if !should_codegen_locally ( tcx, instance) {
1055
1055
return ;
1056
1056
}
1057
1057
if let ty:: InstanceDef :: Intrinsic ( def_id) = instance. def {
@@ -1063,13 +1063,13 @@ fn visit_instance_use<'tcx>(
1063
1063
// codegen a call to that function without generating code for the function itself.
1064
1064
let def_id = tcx. lang_items ( ) . get ( LangItem :: PanicNounwind ) . unwrap ( ) ;
1065
1065
let panic_instance = Instance :: mono ( tcx, def_id) ;
1066
- if should_codegen_locally ( tcx, & panic_instance) {
1066
+ if should_codegen_locally ( tcx, panic_instance) {
1067
1067
output. push ( create_fn_mono_item ( tcx, panic_instance, source) ) ;
1068
1068
}
1069
1069
} else if tcx. has_attr ( def_id, sym:: rustc_intrinsic) {
1070
1070
// Codegen the fallback body of intrinsics with fallback bodies
1071
1071
let instance = ty:: Instance :: new ( def_id, instance. args ) ;
1072
- if should_codegen_locally ( tcx, & instance) {
1072
+ if should_codegen_locally ( tcx, instance) {
1073
1073
output. push ( create_fn_mono_item ( tcx, instance, source) ) ;
1074
1074
}
1075
1075
}
@@ -1107,7 +1107,7 @@ fn visit_instance_use<'tcx>(
1107
1107
1108
1108
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
1109
1109
/// can just link to the upstream crate and therefore don't need a mono item.
1110
- pub ( crate ) fn should_codegen_locally < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : & Instance < ' tcx > ) -> bool {
1110
+ pub ( crate ) fn should_codegen_locally < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
1111
1111
let Some ( def_id) = instance. def . def_id_if_not_guaranteed_local_codegen ( ) else {
1112
1112
return true ;
1113
1113
} ;
@@ -1304,7 +1304,7 @@ fn create_mono_items_for_vtable_methods<'tcx>(
1304
1304
None
1305
1305
}
1306
1306
VtblEntry :: Method ( instance) => {
1307
- Some ( * instance) . filter ( |instance| should_codegen_locally ( tcx, instance) )
1307
+ Some ( * instance) . filter ( |instance| should_codegen_locally ( tcx, * instance) )
1308
1308
}
1309
1309
} )
1310
1310
. map ( |item| create_fn_mono_item ( tcx, item, source) ) ;
@@ -1321,7 +1321,7 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
1321
1321
GlobalAlloc :: Static ( def_id) => {
1322
1322
assert ! ( !tcx. is_thread_local_static( def_id) ) ;
1323
1323
let instance = Instance :: mono ( tcx, def_id) ;
1324
- if should_codegen_locally ( tcx, & instance) {
1324
+ if should_codegen_locally ( tcx, instance) {
1325
1325
trace ! ( "collecting static {:?}" , def_id) ;
1326
1326
output. push ( dummy_spanned ( MonoItem :: Static ( def_id) ) ) ;
1327
1327
}
@@ -1339,7 +1339,7 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
1339
1339
}
1340
1340
}
1341
1341
GlobalAlloc :: Function ( fn_instance) => {
1342
- if should_codegen_locally ( tcx, & fn_instance) {
1342
+ if should_codegen_locally ( tcx, fn_instance) {
1343
1343
trace ! ( "collecting {:?} with {:#?}" , alloc_id, fn_instance) ;
1344
1344
output. push ( create_fn_mono_item ( tcx, fn_instance, DUMMY_SP ) ) ;
1345
1345
}
@@ -1474,7 +1474,7 @@ fn visit_mentioned_item<'tcx>(
1474
1474
if let ty:: Closure ( def_id, args) = * source_ty. kind ( ) {
1475
1475
let instance =
1476
1476
Instance :: resolve_closure ( tcx, def_id, args, ty:: ClosureKind :: FnOnce ) ;
1477
- if should_codegen_locally ( tcx, & instance) {
1477
+ if should_codegen_locally ( tcx, instance) {
1478
1478
output. push ( create_fn_mono_item ( tcx, instance, span) ) ;
1479
1479
}
1480
1480
} else {
@@ -1736,7 +1736,7 @@ fn create_mono_items_for_default_impls<'tcx>(
1736
1736
let instance = ty:: Instance :: expect_resolve ( tcx, param_env, method. def_id , args) ;
1737
1737
1738
1738
let mono_item = create_fn_mono_item ( tcx, instance, DUMMY_SP ) ;
1739
- if mono_item. node . is_instantiable ( tcx) && should_codegen_locally ( tcx, & instance) {
1739
+ if mono_item. node . is_instantiable ( tcx) && should_codegen_locally ( tcx, instance) {
1740
1740
output. push ( mono_item) ;
1741
1741
}
1742
1742
}
0 commit comments