@@ -173,7 +173,7 @@ use rustc_hir::lang_items::LangItem;
173173use rustc_middle:: mir:: interpret:: { AllocId , ErrorHandled , GlobalAlloc , Scalar } ;
174174use rustc_middle:: mir:: mono:: { InstantiationMode , MonoItem } ;
175175use rustc_middle:: mir:: visit:: Visitor as MirVisitor ;
176- use rustc_middle:: mir:: { self , Local , Location } ;
176+ use rustc_middle:: mir:: { self , Location } ;
177177use rustc_middle:: query:: TyCtxtAt ;
178178use rustc_middle:: ty:: adjustment:: { CustomCoerceUnsized , PointerCoercion } ;
179179use rustc_middle:: ty:: print:: with_no_trimmed_paths;
@@ -874,14 +874,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
874874 self . super_operand ( operand, location) ;
875875 self . check_operand_move_size ( operand, location) ;
876876 }
877-
878- fn visit_local (
879- & mut self ,
880- _place_local : Local ,
881- _context : mir:: visit:: PlaceContext ,
882- _location : Location ,
883- ) {
884- }
885877}
886878
887879fn visit_drop_use < ' tcx > (
@@ -1220,7 +1212,7 @@ impl<'v> RootCollector<'_, 'v> {
12201212 }
12211213
12221214 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 )
12241216 && match self . mode {
12251217 MonoItemCollectionMode :: Eager => true ,
12261218 MonoItemCollectionMode :: Lazy => {
@@ -1283,11 +1275,6 @@ impl<'v> RootCollector<'_, 'v> {
12831275 }
12841276}
12851277
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-
12911278#[ instrument( level = "debug" , skip( tcx, output) ) ]
12921279fn create_mono_items_for_default_impls < ' tcx > (
12931280 tcx : TyCtxt < ' tcx > ,
@@ -1394,17 +1381,6 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
13941381 }
13951382}
13961383
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-
14081384fn assoc_fn_of_type < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , fn_ident : Ident ) -> Option < DefId > {
14091385 for impl_def_id in tcx. inherent_impls ( def_id) {
14101386 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) ->
14201396}
14211397
14221398fn 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 < _ > > ( )
14431409}
14441410
14451411/// Scans the MIR in order to find function calls, closures, and drop-glue.
0 commit comments