mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
Rust: Take where clauses into account in path resolution
This commit is contained in:
@@ -581,9 +581,21 @@ private class BlockExprItemNode extends ItemNode instanceof BlockExpr {
|
||||
}
|
||||
|
||||
class TypeParamItemNode extends ItemNode instanceof TypeParam {
|
||||
private WherePred getAWherePred() {
|
||||
exists(ItemNode declaringItem |
|
||||
this = resolveTypeParamPathTypeRepr(result.getTypeRepr()) and
|
||||
result = declaringItem.getADescendant() and
|
||||
this = declaringItem.getADescendant()
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
Path getABoundPath() {
|
||||
result = super.getTypeBoundList().getABound().getTypeRepr().(PathTypeRepr).getPath()
|
||||
exists(TypeBoundList tbl | result = tbl.getABound().getTypeRepr().(PathTypeRepr).getPath() |
|
||||
tbl = super.getTypeBoundList()
|
||||
or
|
||||
tbl = this.getAWherePred().getTypeBoundList()
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
@@ -605,11 +617,7 @@ class TypeParamItemNode extends ItemNode instanceof TypeParam {
|
||||
Stages::PathResolutionStage::ref() and
|
||||
exists(this.getABoundPath())
|
||||
or
|
||||
exists(ItemNode declaringItem, WherePred wp |
|
||||
this = resolveTypeParamPathTypeRepr(wp.getTypeRepr()) and
|
||||
wp = declaringItem.getADescendant() and
|
||||
this = declaringItem.getADescendant()
|
||||
)
|
||||
exists(this.getAWherePred())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -568,7 +568,7 @@ mod m24 {
|
||||
T: TraitA // $ item=I111 item=I1151
|
||||
{
|
||||
fn call_trait_a(&self) {
|
||||
self.data.trait_a_method(); // $ MISSING: item=I110
|
||||
self.data.trait_a_method(); // $ item=I110
|
||||
} // I116
|
||||
}
|
||||
|
||||
@@ -580,8 +580,8 @@ mod m24 {
|
||||
T: TraitA, // $ item=I111 item=I1161
|
||||
{
|
||||
fn call_both(&self) {
|
||||
self.data.trait_a_method(); // $ MISSING: item=I110
|
||||
self.data.trait_b_method(); // $ MISSING: item=I112
|
||||
self.data.trait_a_method(); // $ item=I110
|
||||
self.data.trait_b_method(); // $ item=I112
|
||||
} // I117
|
||||
}
|
||||
|
||||
|
||||
@@ -623,7 +623,7 @@ mod function_trait_bounds_2 {
|
||||
where
|
||||
T1: Into<T2>,
|
||||
{
|
||||
x.into()
|
||||
x.into() // $ method=into
|
||||
}
|
||||
|
||||
pub fn f() {
|
||||
|
||||
Reference in New Issue
Block a user