@@ -24,11 +24,11 @@ use rustc_smir::rustc_internal;
2424use stable_mir:: mir:: mono:: { Instance , InstanceKind } ;
2525use stable_mir:: mir:: visit:: { Location , MirVisitor } ;
2626use stable_mir:: mir:: { LocalDecl , Terminator , TerminatorKind } ;
27- use stable_mir:: ty:: { FnDef , GenericArgs , IntrinsicDef , RigidTy , TyKind } ;
27+ use stable_mir:: ty:: { FnDef , GenericArgs , RigidTy , TyKind } ;
28+ use std:: assert_matches:: assert_matches;
2829use std:: convert:: TryFrom ;
2930use std:: io:: Write ;
3031use std:: ops:: ControlFlow ;
31- use std:: assert_matches:: assert_matches;
3232
3333/// This function tests that we can correctly get type information from binary operations.
3434fn test_intrinsics ( ) -> ControlFlow < ( ) > {
@@ -41,9 +41,9 @@ fn test_intrinsics() -> ControlFlow<()> {
4141
4242 let calls = visitor. calls ;
4343 assert_eq ! ( calls. len( ) , 3 , "Expected 3 calls, but found: {calls:?}" ) ;
44- for ( fn_def, args) in & calls {
45- check_instance ( & Instance :: resolve ( * fn_def, & args) . unwrap ( ) ) ;
46- check_def ( fn_def. as_intrinsic ( ) . unwrap ( ) ) ;
44+ for ( fn_def, args) in calls. into_iter ( ) {
45+ check_instance ( & Instance :: resolve ( fn_def, & args) . unwrap ( ) ) ;
46+ check_def ( fn_def) ;
4747 }
4848
4949 ControlFlow :: Continue ( ( ) )
@@ -68,7 +68,11 @@ fn check_instance(instance: &Instance) {
6868 }
6969}
7070
71- fn check_def ( intrinsic : IntrinsicDef ) {
71+ fn check_def ( fn_def : FnDef ) {
72+ assert ! ( fn_def. is_intrinsic( ) ) ;
73+ let intrinsic = fn_def. as_intrinsic ( ) . unwrap ( ) ;
74+ assert_eq ! ( fn_def, intrinsic. into( ) ) ;
75+
7276 let name = intrinsic. fn_name ( ) ;
7377 match name. as_str ( ) {
7478 "likely" | "size_of_val" => {
0 commit comments