Skip to content

Commit 9c3e362

Browse files
committed
Rust: Add TupleStructPat.getStruct.
1 parent 942a980 commit 9c3e362

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rust/ql/lib/codeql/rust/elements/internal/TupleStructPatImpl.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ module Impl {
3434
exists(this.getField(pragma[only_bind_into](pos)))
3535
}
3636

37+
/**
38+
* Gets the struct matched by this pattern.
39+
*/
40+
Struct getStruct() { result = PathResolution::resolvePath(this.getPath()) }
41+
3742
/** Gets the tuple field that matches the `pos`th pattern of this pattern. */
3843
pragma[nomagic]
3944
TupleField getTupleField(int pos) {

rust/ql/lib/codeql/rust/frameworks/Poem.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ private class PoemHandlerParam extends RemoteSource::Range {
1616
exists(TupleStructPat param, Type t |
1717
this.asPat().getPat() = param.getAField() and
1818
t = inferType(param) and
19-
t.(StructType).asItemNode().(Addressable).getCanonicalPath() =
20-
["poem::web::query::Query", "poem::web::path::Path"]
19+
param.getStruct().getCanonicalPath() = ["poem::web::query::Query", "poem::web::path::Path"]
2120
)
2221
}
2322
}

0 commit comments

Comments
 (0)