@@ -173,7 +173,7 @@ use rustc_hir::lang_items::LangItem;
173
173
use rustc_middle:: mir:: interpret:: { AllocId , ErrorHandled , GlobalAlloc , Scalar } ;
174
174
use rustc_middle:: mir:: mono:: { InstantiationMode , MonoItem } ;
175
175
use rustc_middle:: mir:: visit:: Visitor as MirVisitor ;
176
- use rustc_middle:: mir:: { self , Local , Location } ;
176
+ use rustc_middle:: mir:: { self , Location } ;
177
177
use rustc_middle:: query:: TyCtxtAt ;
178
178
use rustc_middle:: ty:: adjustment:: { CustomCoerceUnsized , PointerCoercion } ;
179
179
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
@@ -874,14 +874,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
874
874
self . super_operand ( operand, location) ;
875
875
self . check_operand_move_size ( operand, location) ;
876
876
}
877
-
878
- fn visit_local (
879
- & mut self ,
880
- _place_local : Local ,
881
- _context : mir:: visit:: PlaceContext ,
882
- _location : Location ,
883
- ) {
884
- }
885
877
}
886
878
887
879
fn visit_drop_use < ' tcx > (
@@ -1220,7 +1212,7 @@ impl<'v> RootCollector<'_, 'v> {
1220
1212
}
1221
1213
1222
1214
fn is_root ( & self , def_id : LocalDefId ) -> bool {
1223
- !item_requires_monomorphization ( self . tcx , def_id)
1215
+ !self . tcx . generics_of ( def_id) . requires_monomorphization ( self . tcx )
1224
1216
&& match self . mode {
1225
1217
MonoItemCollectionMode :: Eager => true ,
1226
1218
MonoItemCollectionMode :: Lazy => {
@@ -1283,11 +1275,6 @@ impl<'v> RootCollector<'_, 'v> {
1283
1275
}
1284
1276
}
1285
1277
1286
- fn item_requires_monomorphization ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> bool {
1287
- let generics = tcx. generics_of ( def_id) ;
1288
- generics. requires_monomorphization ( tcx)
1289
- }
1290
-
1291
1278
#[ instrument( level = "debug" , skip( tcx, output) ) ]
1292
1279
fn create_mono_items_for_default_impls < ' tcx > (
1293
1280
tcx : TyCtxt < ' tcx > ,
@@ -1394,17 +1381,6 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
1394
1381
}
1395
1382
}
1396
1383
1397
- fn add_assoc_fn < ' tcx > (
1398
- tcx : TyCtxt < ' tcx > ,
1399
- def_id : Option < DefId > ,
1400
- fn_ident : Ident ,
1401
- skip_move_check_fns : & mut Vec < DefId > ,
1402
- ) {
1403
- if let Some ( def_id) = def_id. and_then ( |def_id| assoc_fn_of_type ( tcx, def_id, fn_ident) ) {
1404
- skip_move_check_fns. push ( def_id) ;
1405
- }
1406
- }
1407
-
1408
1384
fn assoc_fn_of_type < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , fn_ident : Ident ) -> Option < DefId > {
1409
1385
for impl_def_id in tcx. inherent_impls ( def_id) {
1410
1386
if let Some ( new) = tcx. associated_items ( impl_def_id) . find_by_name_and_kind (
@@ -1420,26 +1396,16 @@ fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) ->
1420
1396
}
1421
1397
1422
1398
fn build_skip_move_check_fns ( tcx : TyCtxt < ' _ > ) -> Vec < DefId > {
1423
- let mut skip_move_check_fns = vec ! [ ] ;
1424
- add_assoc_fn (
1425
- tcx,
1426
- tcx. lang_items ( ) . owned_box ( ) ,
1427
- Ident :: from_str ( "new" ) ,
1428
- & mut skip_move_check_fns,
1429
- ) ;
1430
- add_assoc_fn (
1431
- tcx,
1432
- tcx. get_diagnostic_item ( sym:: Arc ) ,
1433
- Ident :: from_str ( "new" ) ,
1434
- & mut skip_move_check_fns,
1435
- ) ;
1436
- add_assoc_fn (
1437
- tcx,
1438
- tcx. get_diagnostic_item ( sym:: Rc ) ,
1439
- Ident :: from_str ( "new" ) ,
1440
- & mut skip_move_check_fns,
1441
- ) ;
1442
- skip_move_check_fns
1399
+ let fns = [
1400
+ ( tcx. lang_items ( ) . owned_box ( ) , "new" ) ,
1401
+ ( tcx. get_diagnostic_item ( sym:: Rc ) , "new" ) ,
1402
+ ( tcx. get_diagnostic_item ( sym:: Arc ) , "new" ) ,
1403
+ ] ;
1404
+ fns. into_iter ( )
1405
+ . filter_map ( |( def_id, fn_name) | {
1406
+ def_id. and_then ( |def_id| assoc_fn_of_type ( tcx, def_id, Ident :: from_str ( fn_name) ) )
1407
+ } )
1408
+ . collect :: < Vec < _ > > ( )
1443
1409
}
1444
1410
1445
1411
/// Scans the MIR in order to find function calls, closures, and drop-glue.
0 commit comments