[Rust] How do I query function and module attributes?
Open
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
Research direction
Start by locating the Rust CodeQL library definitions for Module, Attr, and Meta, then compare how the #[test] and #[cfg(test)] attributes are represented. Done means providing a documented query pattern that filters tests using these attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100