Rust: Use verbose type paths in inline expectation comments#21778
Open
hvitved wants to merge 2 commits intogithub:mainfrom
Open
Rust: Use verbose type paths in inline expectation comments#21778hvitved wants to merge 2 commits intogithub:mainfrom
hvitved wants to merge 2 commits intogithub:mainfrom
Conversation
de564a5 to
e1cd708
Compare
hvitved
commented
Apr 30, 2026
| for cell in row { // $ MISSING: type=cell:i32 | ||
| } | ||
| }; | ||
|
|
||
| let mut map1 = std::collections::HashMap::new(); // $ target=new type=map1:K.i32 type=map1:V.Box $ MISSING: type=map1:Hashmap type1=map1:V.T.TRef.str | ||
| let mut map1 = std::collections::HashMap::new(); // $ target=new type=map1@HashMap<K>:i32 type=map1@HashMap<V>.Box<T>.&<TRef>:str |
Contributor
Author
There was a problem hiding this comment.
The MISSING parts were in fact not missing; the first misspelled Hashmap and the second misspelled type1.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Rust type-inference inline expectation tests to use a more verbose, owner-qualified type-path format (matching the approach used in #21777), making expectations easier to verify by humans and unambiguous when type parameters share names.
Changes:
- Add
TypePath::printTypePathVerboseto produce owner-qualified type-parameter paths (for exampleS1<T1>.S2<T2>). - Update the Rust type-inference inline-expectations harness to emit
element@<verbose-type-path>:<type>for non-emptyTypePaths. - Migrate Rust type-inference library test
.rsfiles to the new inline expectation comment format.
Show a summary per file
| File | Description |
|---|---|
| shared/typeinference/codeql/typeinference/internal/TypeInference.qll | Introduces verbose printing for type paths by including the owning type of each type parameter. |
| rust/ql/test/library-tests/type-inference/type-inference.ql | Changes emitted expectation value format to include @<verbose-type-path> for nested type paths. |
| rust/ql/test/library-tests/type-inference/regressions.rs | Updates regression inline expectations to the new verbose type-path format. |
| rust/ql/test/library-tests/type-inference/raw_pointer.rs | Updates raw-pointer type expectations to the new verbose format. |
| rust/ql/test/library-tests/type-inference/pattern_matching.rs | Updates pattern-matching type expectations to the new verbose format. |
| rust/ql/test/library-tests/type-inference/main.rs | Broad updates to type inference expectations across many Rust constructs (generics, collections, ranges, etc.). |
| rust/ql/test/library-tests/type-inference/dereference.rs | Updates dereference-related type expectations to the new verbose format. |
| rust/ql/test/library-tests/type-inference/associated_types.rs | Updates associated-type expectations to the new verbose format. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the inline type test expectations to follow the same format as in #21777. For example, for a variable
xof typeResult<Option<i32>, bool>we would previously have these four commentsbut now we instead have the more verbose (and human verifiable) format
Note that since the type parameters are tagged with the types that they belong to, we can distinguish the two parameters both named
T, and there is also no need to add the commentstype=x:Resultandtype=x@Result<T>:Option(the former is implied by both comments, the latter is implied by the first comment).