Skip to content

Commit fd9f2fb

Browse files
committed
Rust: Macro call resolution
1 parent f4388c8 commit fd9f2fb

File tree

22 files changed

+356
-250
lines changed

22 files changed

+356
-250
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub fn hello() {
2-
println!("Hello, world!");
2+
println!("Hello, world!"); // $ item=println
33
} // HELLO

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ private import codeql.rust.elements.internal.generated.MacroCall
1212
*/
1313
module Impl {
1414
private import rust
15+
private import codeql.rust.internal.PathResolution
1516

1617
pragma[nomagic]
1718
predicate isInMacroExpansion(AstNode root, AstNode n) {
@@ -44,5 +45,12 @@ module Impl {
4445
isInMacroExpansion(this, result) and
4546
this.getTokenTree().getLocation().contains(result.getLocation())
4647
}
48+
49+
/**
50+
* Gets the macro definition that this macro call resolves to.
51+
*
52+
* The result is either a `MacroDef` or a `MacroRules`.
53+
*/
54+
Item resolveMacro() { result = resolvePath(this.getPath()) }
4755
}
4856
}

0 commit comments

Comments
 (0)