@@ -847,159 +847,6 @@ private predicate functionInfoBlanket(
847847 )
848848}
849849
850- /**
851- * A wrapper around `IsInstantiationOf` which ensures to substitute in lookup
852- * traits when checking whether argument types are instantiations of function
853- * types.
854- */
855- private module ArgIsInstantiationOf<
856- HasTypeTreeSig Arg, IsInstantiationOfInputSig< Arg , FunctionType > Input>
857- {
858- final private class ArgFinal = Arg ;
859-
860- private class ArgSubst extends ArgFinal {
861- Type getTypeAt ( TypePath path ) { result = substituteLookupTraits ( super .getTypeAt ( path ) ) }
862- }
863-
864- private module IsInstantiationOfInput implements IsInstantiationOfInputSig< ArgSubst , FunctionType >
865- {
866- pragma [ nomagic]
867- predicate potentialInstantiationOf ( ArgSubst arg , TypeAbstraction abs , FunctionType constraint ) {
868- Input:: potentialInstantiationOf ( arg , abs , constraint )
869- }
870-
871- predicate relevantTypeMention ( FunctionType constraint ) {
872- Input:: relevantTypeMention ( constraint )
873- }
874- }
875-
876- predicate argIsInstantiationOf ( Arg arg , ImplOrTraitItemNode i , FunctionType constraint ) {
877- IsInstantiationOf< ArgSubst , FunctionType , IsInstantiationOfInput > :: isInstantiationOf ( arg , i ,
878- constraint )
879- }
880-
881- predicate argIsNotInstantiationOf ( Arg arg , ImplOrTraitItemNode i , FunctionType constraint ) {
882- IsInstantiationOf< ArgSubst , FunctionType , IsInstantiationOfInput > :: isNotInstantiationOf ( arg , i ,
883- constraint )
884- }
885- }
886-
887- signature module ArgsAreInstantiationsOfInputSig {
888- predicate toCheck ( ImplOrTraitItemNode i , Function f , FunctionTypePosition pos , FunctionType t ) ;
889-
890- class Call {
891- string toString ( ) ;
892-
893- Location getLocation ( ) ;
894-
895- Type getArgType ( FunctionTypePosition pos , TypePath path ) ;
896-
897- predicate hasTargetCand ( ImplOrTraitItemNode i , Function f ) ;
898- }
899- }
900-
901- /**
902- * A wrapper around `IsInstantiationOf` which ensures to substitute in lookup
903- * traits when checking whether argument types are instantiations of function
904- * types.
905- */
906- private module ArgsAreInstantiationsOf< ArgsAreInstantiationsOfInputSig Input> {
907- pragma [ nomagic]
908- private predicate toCheckRanked (
909- ImplOrTraitItemNode i , Function f , FunctionTypePosition pos , int rnk
910- ) {
911- Input:: toCheck ( i , f , pos , _) and
912- pos =
913- rank [ rnk + 1 ] ( FunctionTypePosition pos0 , int j |
914- Input:: toCheck ( i , f , pos0 , _) and
915- (
916- j = pos0 .asPositional ( )
917- or
918- pos0 .isSelf ( ) and j = - 1
919- or
920- pos0 .isReturn ( ) and j = - 2
921- )
922- |
923- pos0 order by j
924- )
925- }
926-
927- private newtype TCallAndPos =
928- MkCallAndPos ( Input:: Call call , FunctionTypePosition pos ) {
929- exists ( call .getArgType ( pos , _) )
930- // exists(ImplOrTraitItemNode i, Function f |
931- // Input::toCheck(i, f, pos, _) and
932- // call.hasTargetCand(i, f)
933- // )
934- }
935-
936- /** A call tagged with a position. */
937- private class CallAndPos extends MkCallAndPos {
938- Input:: Call call ;
939- FunctionTypePosition pos ;
940-
941- CallAndPos ( ) { this = MkCallAndPos ( call , pos ) }
942-
943- Input:: Call getCall ( ) { result = call }
944-
945- FunctionTypePosition getPos ( ) { result = pos }
946-
947- Location getLocation ( ) { result = call .getLocation ( ) }
948-
949- Type getTypeAt ( TypePath path ) { result = call .getArgType ( pos , path ) }
950-
951- string toString ( ) { result = call .toString ( ) + " [arg " + pos + "]" }
952- }
953-
954- private module ArgIsIsInstantiationOfInput implements
955- IsInstantiationOfInputSig< CallAndPos , FunctionType >
956- {
957- pragma [ nomagic]
958- private predicate potentialInstantiationOf0 (
959- CallAndPos cp , Input:: Call call , FunctionTypePosition pos , int rnk , Function f ,
960- TypeAbstraction abs , FunctionType constraint
961- ) {
962- cp = MkCallAndPos ( call , pos ) and
963- call .hasTargetCand ( abs , f ) and
964- toCheckRanked ( abs , f , pos , rnk ) and
965- Input:: toCheck ( abs , f , pos , constraint )
966- }
967-
968- pragma [ nomagic]
969- predicate potentialInstantiationOf ( CallAndPos cp , TypeAbstraction abs , FunctionType constraint ) {
970- exists ( Input:: Call call , FunctionTypePosition pos , int rnk , Function f |
971- potentialInstantiationOf0 ( cp , call , pos , rnk , f , abs , constraint )
972- |
973- rnk = 0
974- or
975- argsAreInstantiationsOfFromIndex ( call , abs , f , rnk - 1 )
976- )
977- }
978-
979- predicate relevantTypeMention ( FunctionType constraint ) { Input:: toCheck ( _, _, _, constraint ) }
980- }
981-
982- pragma [ nomagic]
983- private predicate argsAreInstantiationsOfFromIndex (
984- Input:: Call call , ImplOrTraitItemNode i , Function f , int rnk
985- ) {
986- exists ( FunctionTypePosition pos |
987- ArgIsInstantiationOf< CallAndPos , ArgIsIsInstantiationOfInput > :: argIsInstantiationOf ( MkCallAndPos ( call ,
988- pos ) , i , _) and
989- call .hasTargetCand ( i , f ) and
990- toCheckRanked ( i , f , pos , rnk )
991- )
992- }
993-
994- pragma [ nomagic]
995- predicate argsAreInstantiationsOf ( Input:: Call call , ImplOrTraitItemNode i , Function f ) {
996- exists ( int rnk |
997- argsAreInstantiationsOfFromIndex ( call , i , f , rnk ) and
998- rnk = max ( int r | toCheckRanked ( i , f , _, r ) )
999- )
1000- }
1001- }
1002-
1003850/**
1004851 * Holds if the type path `path` pointing to `type` is stripped of any leading
1005852 * complex root type allowed for `self` parameters, such as `&`, `Box`, `Rc`,
0 commit comments