Rust: Improve and rename Adt class#21059
Merged
Merged
Conversation
4328d9f to
043d99c
Compare
043d99c to
97fd70e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR renames the Adt class to TypeItem and refactors it to move common member predicates (attrs, generic_param_list, name, visibility, where_clause) from the individual subclasses (Struct, Enum, Union) to their common superclass. This improves code reusability and makes the class name more descriptive, as it represents items that define types rather than strictly algebraic data types.
Key changes:
- Renamed
Adtclass toTypeItemthroughout the codebase - Moved common predicates from
Struct,Enum, andUniontoTypeItemsuperclass - Updated database schema relations to consolidate duplicated table definitions
- Provided upgrade/downgrade scripts for database migration
Reviewed changes
Copilot reviewed 23 out of 40 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rust/schema/ast.py | Renamed Adt to TypeItem in base class definitions |
| rust/schema/annotations.py | Added common predicates to TypeItem annotation and dropped them from subclasses |
| rust/ql/lib/rust.dbscheme | Consolidated common relations into type_item_* tables, removed duplicates |
| rust/ql/lib/upgrades/e54d01f67a416b3d6eb7b970f27295097f2cac7f/* | Database upgrade scripts for the schema migration |
| rust/downgrades/c467bf63916002287b7bde8ce8b094c57579bd81/* | Database downgrade scripts for rollback capability |
| rust/ql/lib/codeql/rust/elements/* | Updated QL library files to use new TypeItem class |
| rust/ql/test/extractor-tests/macro-expansion/test.ql | Updated test to use TypeItem instead of Adt |
| rust/extractor/src/* | Updated Rust extractor code to use TypeItem |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hvitved
approved these changes
Dec 18, 2025
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.
This PR:
Struct,Enum, andUnionhave in common to their common superclassAdt. This makes the class much more useful.Adtclass toTypeItem. Here's a few reasons, that I thinkTypeItemaddresses:rust.ungram.unionis included which strictly speaking isn't an algebraic type.