Skip to content

Commit c70198e

Browse files
committed
Rust: change dummy macro call expansion
1 parent bf09c92 commit c70198e

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

rust/extractor/src/translate/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,9 @@ impl<'a> Translator<'a> {
910910
path: None,
911911
token_tree: None,
912912
});
913-
generated::MacroCall::emit_macro_call_expansion(
914-
label,
915-
expanded.into(),
913+
generated::Item::emit_attribute_macro_expansion(
914+
label.into(),
915+
expanded,
916916
&mut self.trap.writer,
917917
);
918918
self.emit_location(label, node);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ module Impl {
3232
* ```
3333
*/
3434
class MacroCall extends Generated::MacroCall {
35-
override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "!..." }
35+
override string toStringImpl() {
36+
if this.hasPath() then result = this.getPath().toAbbreviatedString() + "!..." else result = ""
37+
}
3638

3739
/** Gets an AST node whose location is inside the token tree belonging to this macro call. */
3840
pragma[nomagic]

rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ lib.rs:
55
# 1| getVisibility(): [Visibility] Visibility
66
macro_in_library.rs:
77
# 1| [SourceFile] SourceFile
8+
# 1| getItem(0): [MacroCall]
9+
# 2| getAttributeMacroExpansion(): [MacroItems] MacroItems
10+
# 2| getItem(0): [Function] fn foo
11+
# 2| getParamList(): [ParamList] ParamList
12+
# 2| getName(): [Name] foo
13+
# 2| getVisibility(): [Visibility] Visibility
14+
# 2| getItem(1): [Function] fn foo_new
15+
# 2| getParamList(): [ParamList] ParamList
16+
# 2| getName(): [Name] foo_new
17+
# 2| getVisibility(): [Visibility] Visibility
818
# 4| getItem(1): [Function] fn bar
919
# 4| getParamList(): [ParamList] ParamList
1020
# 4| getName(): [Name] bar
1121
# 4| getVisibility(): [Visibility] Visibility
12-
# 2| [MacroItems] MacroItems
13-
# 2| getItem(0): [Function] fn foo
14-
# 2| getParamList(): [ParamList] ParamList
15-
# 2| getName(): [Name] foo
16-
# 2| getVisibility(): [Visibility] Visibility
17-
# 2| getItem(1): [Function] fn foo_new
18-
# 2| getParamList(): [ParamList] ParamList
19-
# 2| getName(): [Name] foo_new
20-
# 2| getVisibility(): [Visibility] Visibility
2122
proc_macro.rs:
2223
# 1| [SourceFile] SourceFile
2324
# 1| getItem(0): [Use] use ...::TokenStream

0 commit comments

Comments
 (0)