mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: Split getFunctionReturnPos into two predicates
This commit is contained in:
@@ -23,10 +23,14 @@ module Impl {
|
||||
* ```
|
||||
*/
|
||||
class ImplTraitTypeRepr extends Generated::ImplTraitTypeRepr {
|
||||
/**
|
||||
* Gets the function for which this impl trait type occurs in the return
|
||||
* type, if any.
|
||||
*/
|
||||
Function getFunctionReturnPos() { this.getParentNode*() = result.getRetType().getTypeRepr() }
|
||||
/** Gets the function for which this impl trait type occurs, if any. */
|
||||
Function getFunction() {
|
||||
this.getParentNode*() = [result.getRetType().getTypeRepr(), result.getAParam().getTypeRepr()]
|
||||
}
|
||||
|
||||
/** Holds if this impl trait type occurs in the return type of a function. */
|
||||
predicate isInReturnPos() {
|
||||
this.getParentNode*() = this.getFunction().getRetType().getTypeRepr()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ newtype TType =
|
||||
TSliceTypeParameter()
|
||||
|
||||
predicate implTraitTypeParam(ImplTraitTypeRepr implTrait, int i, TypeParam tp) {
|
||||
tp = implTrait.getFunctionReturnPos().getGenericParamList().getTypeParam(i) and
|
||||
implTrait.isInReturnPos() and
|
||||
tp = implTrait.getFunction().getGenericParamList().getTypeParam(i) and
|
||||
// Only include type parameters of the function that occur inside the impl
|
||||
// trait type.
|
||||
exists(Path path | path.getParentNode*() = implTrait and resolvePath(path) = tp)
|
||||
@@ -317,7 +318,7 @@ class DynTraitType extends Type, TDynTraitType {
|
||||
class ImplTraitReturnType extends ImplTraitType {
|
||||
private Function function;
|
||||
|
||||
ImplTraitReturnType() { function = impl.getFunctionReturnPos() }
|
||||
ImplTraitReturnType() { impl.isInReturnPos() and function = impl.getFunction() }
|
||||
|
||||
override Function getFunction() { result = function }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user