@@ -849,19 +849,30 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
849
849
}
850
850
}
851
851
852
- struct FunctionCallFinder {
852
+ struct FunctionCallFinder < ' tcx > {
853
+ tcx : TyCtxt < ' tcx > ,
853
854
found : bool ,
854
855
}
855
856
856
- impl FunctionCallFinder {
857
- fn new ( ) -> Self {
858
- FunctionCallFinder { found : false }
857
+ impl < ' tcx > FunctionCallFinder < ' tcx > {
858
+ fn new ( tcx : TyCtxt < ' tcx > ) -> Self {
859
+ FunctionCallFinder { tcx , found : false }
859
860
}
860
861
}
861
862
862
- impl < ' tcx > Visitor < ' tcx > for FunctionCallFinder {
863
+ impl < ' tcx > Visitor < ' tcx > for FunctionCallFinder < ' tcx > {
863
864
fn visit_terminator ( & mut self , terminator : & Terminator < ' tcx > , _location : Location ) {
864
- if let TerminatorKind :: Call { .. } = terminator. kind {
865
+ if let TerminatorKind :: Call { func : Operand :: Constant ( ref f) , .. } = terminator. kind {
866
+ if let ty:: FnDef ( def_id, _) = * f. literal . ty . kind ( ) {
867
+ // Don't forbid intrinsics.
868
+ let f = self . tcx . fn_sig ( def_id) ;
869
+ if f. abi ( ) == Abi :: RustIntrinsic || f. abi ( ) == Abi :: PlatformIntrinsic {
870
+ return ;
871
+ }
872
+
873
+ // FIXME: We may also want to check for `tcx.is_mir_available(def_id)`.
874
+ }
875
+
865
876
self . found = true ;
866
877
}
867
878
}
@@ -884,7 +895,7 @@ pub fn is_trivial_mir(tcx: TyCtxt<'tcx>, did: DefId) -> bool {
884
895
let body = tcx
885
896
. mir_drops_elaborated_and_const_checked ( ty:: WithOptConstParam :: unknown ( did) )
886
897
. borrow ( ) ;
887
- let mut finder = FunctionCallFinder :: new ( ) ;
898
+ let mut finder = FunctionCallFinder :: new ( tcx ) ;
888
899
finder. visit_body ( & body) ;
889
900
debug ! ( "is_trivial_mir = {}" , !finder. found) ;
890
901
!finder. found
0 commit comments