205205//! this is not implemented however: a mono item will be produced
206206//! regardless of whether it is actually needed or not.
207207
208- mod abi_check;
209- mod move_check;
210-
211208use std:: path:: PathBuf ;
212209
213- use move_check:: MoveCheckState ;
214- use rustc_abi:: Size ;
215210use rustc_data_structures:: sync:: { LRef , MTLock , par_for_each_in} ;
216211use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
217212use rustc_hir as hir;
@@ -228,15 +223,15 @@ use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion};
228223use rustc_middle:: ty:: layout:: ValidityRequirement ;
229224use rustc_middle:: ty:: print:: { shrunk_instance_name, with_no_trimmed_paths} ;
230225use rustc_middle:: ty:: {
231- self , AssocKind , GenericArgs , GenericParamDefKind , Instance , InstanceKind , Ty , TyCtxt ,
232- TypeFoldable , TypeVisitableExt , VtblEntry ,
226+ self , GenericArgs , GenericParamDefKind , Instance , InstanceKind , Ty , TyCtxt , TypeFoldable ,
227+ TypeVisitableExt , VtblEntry ,
233228} ;
234229use rustc_middle:: util:: Providers ;
235230use rustc_middle:: { bug, span_bug} ;
236231use rustc_session:: Limit ;
237232use rustc_session:: config:: EntryFnType ;
238233use rustc_span:: source_map:: { Spanned , dummy_spanned, respan} ;
239- use rustc_span:: symbol:: { Ident , sym} ;
234+ use rustc_span:: symbol:: sym;
240235use rustc_span:: { DUMMY_SP , Span } ;
241236use tracing:: { debug, instrument, trace} ;
242237
@@ -612,8 +607,6 @@ struct MirUsedCollector<'a, 'tcx> {
612607 /// Note that this contains *not-monomorphized* items!
613608 used_mentioned_items : & ' a mut UnordSet < MentionedItem < ' tcx > > ,
614609 instance : Instance < ' tcx > ,
615- visiting_call_terminator : bool ,
616- move_check : move_check:: MoveCheckState ,
617610}
618611
619612impl < ' a , ' tcx > MirUsedCollector < ' a , ' tcx > {
@@ -760,13 +753,12 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
760753 } ;
761754
762755 match terminator. kind {
763- mir:: TerminatorKind :: Call { ref func, ref args , ref fn_span , .. }
764- | mir:: TerminatorKind :: TailCall { ref func, ref args , ref fn_span } => {
756+ mir:: TerminatorKind :: Call { ref func, .. }
757+ | mir:: TerminatorKind :: TailCall { ref func, .. } => {
765758 let callee_ty = func. ty ( self . body , tcx) ;
766759 // *Before* monomorphizing, record that we already handled this mention.
767760 self . used_mentioned_items . insert ( MentionedItem :: Fn ( callee_ty) ) ;
768761 let callee_ty = self . monomorphize ( callee_ty) ;
769- self . check_fn_args_move_size ( callee_ty, args, * fn_span, location) ;
770762 visit_fn_use ( self . tcx , callee_ty, true , source, & mut self . used_items )
771763 }
772764 mir:: TerminatorKind :: Drop { ref place, .. } => {
@@ -826,14 +818,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
826818 push_mono_lang_item ( self , reason. lang_item ( ) ) ;
827819 }
828820
829- self . visiting_call_terminator = matches ! ( terminator. kind, mir:: TerminatorKind :: Call { .. } ) ;
830821 self . super_terminator ( terminator, location) ;
831- self . visiting_call_terminator = false ;
832- }
833-
834- fn visit_operand ( & mut self , operand : & mir:: Operand < ' tcx > , location : Location ) {
835- self . super_operand ( operand, location) ;
836- self . check_operand_move_size ( operand, location) ;
837822 }
838823}
839824
@@ -1183,20 +1168,6 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
11831168 }
11841169}
11851170
1186- fn assoc_fn_of_type < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId , fn_ident : Ident ) -> Option < DefId > {
1187- for impl_def_id in tcx. inherent_impls ( def_id) {
1188- if let Some ( new) = tcx. associated_items ( impl_def_id) . find_by_name_and_kind (
1189- tcx,
1190- fn_ident,
1191- AssocKind :: Fn ,
1192- def_id,
1193- ) {
1194- return Some ( new. def_id ) ;
1195- }
1196- }
1197- None
1198- }
1199-
12001171/// Scans the MIR in order to find function calls, closures, and drop-glue.
12011172///
12021173/// Anything that's found is added to `output`. Furthermore the "mentioned items" of the MIR are returned.
@@ -1208,7 +1179,8 @@ fn collect_items_of_instance<'tcx>(
12081179 mentioned_items : & mut MonoItems < ' tcx > ,
12091180 mode : CollectionMode ,
12101181) {
1211- tcx. ensure ( ) . check_feature_dependent_abi ( instance) ;
1182+ // This item is getting monomorphized, do mono-time checks.
1183+ tcx. ensure ( ) . check_mono_item ( instance) ;
12121184
12131185 let body = tcx. instance_mir ( instance. def ) ;
12141186 // Naively, in "used" collection mode, all functions get added to *both* `used_items` and
@@ -1228,8 +1200,6 @@ fn collect_items_of_instance<'tcx>(
12281200 used_items,
12291201 used_mentioned_items : & mut used_mentioned_items,
12301202 instance,
1231- visiting_call_terminator : false ,
1232- move_check : MoveCheckState :: new ( ) ,
12331203 } ;
12341204
12351205 if mode == CollectionMode :: UsedItems {
@@ -1626,5 +1596,4 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
16261596
16271597pub ( crate ) fn provide ( providers : & mut Providers ) {
16281598 providers. hooks . should_codegen_locally = should_codegen_locally;
1629- abi_check:: provide ( providers) ;
16301599}
0 commit comments