Skip to content

Commit dcc9129

Browse files
redsun82Copilot
andcommitted
Rust: adapt QL library to ra_ap 0.0.347 schema
Update hand-written library predicates for the 0.0.347 AST changes: - FormatArgsArg.getArgName() -> getName() (the arg name is now a Name, carrying text, instead of the text-less FormatArgsArgName placeholder). - Visibility.getPath()/hasPath() -> getVisibilityInner().getPath(); the path now hangs off an intermediate VisibilityInner node. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 890cb55d-0437-4bd7-9268-87b8897ada01
1 parent 48718e5 commit dcc9129

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎rust/ql/lib/codeql/rust/elements/internal/FormatTemplateVariableAccessConstructor.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private predicate formatArgsHasArg(
3636

3737
pragma[nomagic]
3838
private predicate formatArgsHasArgName(Raw::FormatArgsExpr parent) {
39-
exists(parent.getArg(_).getArgName())
39+
exists(parent.getArg(_).getName())
4040
}
4141

4242
/**

‎rust/ql/lib/codeql/rust/elements/internal/VisibilityImpl.qll‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ module Impl {
2525
override string toStringImpl() { result = this.toAbbreviatedString() }
2626

2727
override string toAbbreviatedString() {
28-
result = "pub(" + this.getPath().toAbbreviatedString() + ")"
28+
result = "pub(" + this.getVisibilityInner().getPath().toAbbreviatedString() + ")"
2929
or
30-
not this.hasPath() and result = "pub"
30+
not exists(this.getVisibilityInner().getPath()) and result = "pub"
3131
}
3232
}
3333
}

‎rust/ql/lib/codeql/rust/internal/Definitions.qll‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private import codeql.rust.elements.Variable
88
private import codeql.rust.elements.Locatable
99
private import codeql.rust.elements.FormatArgsExpr
1010
private import codeql.rust.elements.FormatArgsArg
11-
private import codeql.rust.elements.FormatArgsArgName
11+
private import codeql.rust.elements.Name
1212
private import codeql.rust.elements.Format
1313
private import codeql.rust.elements.MacroCall
1414
private import codeql.rust.elements.NamedFormatArgument
@@ -34,7 +34,7 @@ private module Cached {
3434
cached
3535
newtype TDef =
3636
TVariable(Variable v) or
37-
TFormatArgsArgDef(FormatArgsArgName name) { name = any(FormatArgsArg a).getArgName() } or
37+
TFormatArgsArgDef(Name name) { name = any(FormatArgsArg a).getName() } or
3838
TFormatArgsArgIndex(Expr e) { e = any(FormatArgsArg a).getExpr() } or
3939
TItemNode(ItemNode i)
4040

@@ -68,7 +68,7 @@ class Definition extends Cached::TDef {
6868
Variable asVariable() { this = Cached::TVariable(result) }
6969

7070
/** Gets this definition as a format argument name */
71-
FormatArgsArgName asFormatArgsArgName() { this = Cached::TFormatArgsArgDef(result) }
71+
Name asFormatArgsArgName() { this = Cached::TFormatArgsArgDef(result) }
7272

7373
/** Gets this definition as an `Expr` */
7474
Expr asExpr() { this = Cached::TFormatArgsArgIndex(result) }
@@ -96,12 +96,12 @@ private class LocalVariableUse extends Use instanceof VariableAccess {
9696
}
9797

9898
private class NamedFormatArgumentUse extends Use instanceof NamedFormatArgument {
99-
private FormatArgsArgName def;
99+
private Name def;
100100

101101
NamedFormatArgumentUse() {
102102
exists(FormatArgsExpr parent |
103103
parent = this.getParent().getParent() and
104-
parent.getAnArg().getArgName() = def
104+
parent.getAnArg().getName() = def
105105
)
106106
}
107107

‎rust/ql/lib/codeql/rust/internal/PathResolution.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ private predicate pathUsesNamespace(PathExt p, Namespace n) {
19621962
or
19631963
n.isType() and
19641964
(
1965-
p = any(Visibility v).getPath()
1965+
p = any(Visibility v).getVisibilityInner().getPath()
19661966
or
19671967
p = any(StructExpr re).getPath()
19681968
or

0 commit comments

Comments
 (0)