github / github/codeql

[Rust] How do I query function and module attributes?

Open
#20,771 2 comments 0 reactions 0 assignees View on GitHub
question Rust
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

I wanted to filter out tests from my results, based on if they either had a #[test] attribute or #[cfg(test)].

Currently tried something similar to this but cant figure out how to properly filter this from the docs

```ql
predicate doesntWork(Module mod, Attr a, Meta m) {
a = mod.getAnAttr() and
m = a.getMeta() and
m.hasPath() and
m.getPath().toString() = "cfg" and
m.hasTokenTree()
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.