-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: add documentation for AST nodes #19630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
353c39f
to
628a741
Compare
628a741
to
858e372
Compare
858e372
to
943dd8e
Compare
883aa89
to
ae0c547
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds detailed documentation comments for various Rust AST node classes and updates the .gitattributes
to include generated test files that were previously marked as missing.
- Enriches QLL class docs with clear descriptions and examples for associated items, inline assembly elements, array types, argument lists, and ABI specs.
- Introduces a constructor predicate in
ControlFlowGraphImpl.qll
to filter out macro pattern calls. - Replaces
MISSING_SOURCE.txt
entries in.gitattributes
with actual.ql
test paths for inline assembly and other elements.
Reviewed Changes
Copilot reviewed 644 out of 644 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
rust/ql/lib/codeql/rust/elements/AssocTypeArg.qll | Added a descriptive doc comment and example for associated type arguments. |
rust/ql/lib/codeql/rust/elements/AssocItemList.qll | Extended doc to mention Impl contexts; refined formatting. |
rust/ql/lib/codeql/rust/elements/AssocItem.qll | Updated comment to describe associated items in traits/impls with example. |
rust/ql/lib/codeql/rust/elements/Asm*.qll | Added docs and examples for inline assembly symbols, registers, options, etc. |
rust/ql/lib/codeql/rust/elements/ArrayTypeRepr.qll | Documented array type representations with example. |
rust/ql/lib/codeql/rust/elements/ArgList.qll | Clarified argument list usage in calls with example. |
rust/ql/lib/codeql/rust/elements/Abi.qll | Documented ABI specs for extern functions/blocks. |
rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll | Added MacroCallTree() predicate to exclude calls in macro patterns. |
rust/ql/.gitattributes | Replaced missing-source placeholders with actual generated .ql test entries. |
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | no-match | test.rs:455:13:455:25 | one_or_two!... | | ||
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | no-match | test.rs:456:13:456:13 | _ | | ||
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | match | test.rs:455:13:455:25 | one_or_two!... | | ||
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | match | test.rs:455:30:455:30 | 3 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Foo<'a> | ||
// ^^ | ||
let text: Text<'a>; | ||
// ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improvements to examples 👍.
| gen_arg_list.rs:5:5:5:11 | ArgList | 0 | gen_arg_list.rs:5:5:5:11 | "not yet implemented" | | ||
| gen_arg_list.rs:7:8:7:16 | ArgList | 0 | gen_arg_list.rs:7:9:7:9 | 1 | | ||
| gen_arg_list.rs:7:8:7:16 | ArgList | 1 | gen_arg_list.rs:7:12:7:12 | 2 | | ||
| gen_arg_list.rs:7:8:7:16 | ArgList | 2 | gen_arg_list.rs:7:15:7:15 | 3 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we getting better test results from doc changes? Are these the tests of the example code you were talking about earlier today?
```rust | ||
todo!() | ||
extern "C" fn foo() {} | ||
// ^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New documentation 👍 (I won't claim to have picked through it with a fine-toothed comb, but it all looks good at a glance, and is certainly an improvement on all those todo!()
s).
```rust | ||
todo!() | ||
fn foo<T, U>(t: T, u: U) {} | ||
// ^ ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ^
are a helpful addition in many of these examples.
(x + y) | ||
//^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(x + y) | |
//^^^^^ | |
(x + y) | |
//^^^^^^^ |
pub struct S; | ||
//^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub struct S; | |
//^^^ | |
pub struct S; | |
//^^^ |
``` | ||
""" | ||
|
||
|
||
@annotate(UseTree) | ||
class _: | ||
""" | ||
A UseTree. For example: | ||
A `use` tree, ie the part after the `use` keyword in a `use` statement. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A `use` tree, ie the part after the `use` keyword in a `use` statement. For example: | |
A `use` tree, that is, the part after the `use` keyword in a `use` statement. For example: |
We're supposed to prefer "that is" to "ie" in documentation.
x: i32, | ||
y: i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x: i32, | |
y: i32, | |
x: i32, | |
y: i32, |
use std::{fs, io}; | ||
// ^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use std::{fs, io}; | |
// ^^^^^^^ | |
use std::{fs, io}; | |
// ^^^^^^^^ |
I'm not sure if this range should include both {}
or neither, but it surely should not include one but not the other. (nit)
@@ -1069,9 +1142,17 @@ class _: | |||
@annotate(ForTypeRepr) | |||
class _: | |||
""" | |||
A ForTypeRepr. For example: | |||
A higher-ranked trait bound(HRTB) type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A higher-ranked trait bound(HRTB) type. | |
A higher-ranked trait bound (HRTB). |
println!("{} {}!", "Hello", "world"); | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
``` | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
```rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, that's a very good improvement in both documentation and testing 👍
Some minor cosmetic nits, but this is really neat!
This pull request adds missing documentation for Rust AST nodes. Best reviewed commit-by-commit, skipping the codegen ones. The most important changed files is
rust/schema/annotations.py
where the missing documentation was added.