Skip to content

Commit e4f8758

Browse files
committed
Rust: Account for attribute expansions in path resolution
1 parent aab0279 commit e4f8758

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ private ItemNode getAChildSuccessor(ItemNode item, string name, SuccessorKind ki
156156
* - https://doc.rust-lang.org/reference/names/namespaces.html
157157
*/
158158
abstract class ItemNode extends Locatable {
159+
ItemNode() {
160+
// Exclude items that are superceded by the expansion of an attribute macro.
161+
not this.(Item).hasAttributeMacroExpansion()
162+
}
163+
159164
/** Gets the (original) name of this item. */
160165
abstract string getName();
161166

@@ -648,11 +653,7 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
648653

649654
override Visibility getVisibility() { result = Impl.super.getVisibility() }
650655

651-
TypeParamItemNode getBlanketImplementationTypeParam() {
652-
result = this.resolveSelfTy() and
653-
// This impl block is not superseded by the expansion of an attribute macro.
654-
not exists(super.getAttributeMacroExpansion())
655-
}
656+
TypeParamItemNode getBlanketImplementationTypeParam() { result = this.resolveSelfTy() }
656657

657658
/**
658659
* Holds if this impl block is a blanket implementation. That is, the

rust/ql/test/library-tests/path-resolution/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ fn main() {
792792
m23::f(); // $ item=I108
793793
m24::f(); // $ item=I121
794794
zelf::h(); // $ item=I25
795-
z_changed(); // $ MISSING: item=I122
796-
AStruct::z_on_type(); // $ MISSING: item=I124
795+
z_changed(); // $ item=I122
796+
AStruct::z_on_type(); // $ item=I124
797797
AStruct {} // $ item=I123
798-
.z_on_instance(); // MISSING: item=I125
798+
.z_on_instance(); // item=I125
799799
}

0 commit comments

Comments
 (0)