-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Improve and rename Adt class
#21059
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
| private import internal.TypeItemImpl | ||
| import codeql.rust.elements.Attr | ||
| import codeql.rust.elements.GenericParamList | ||
| import codeql.rust.elements.Item |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.MacroItems
| import codeql.rust.elements.Attr | ||
| import codeql.rust.elements.GenericParamList | ||
| import codeql.rust.elements.Item | ||
| import codeql.rust.elements.MacroItems |
Check warning
Code scanning / CodeQL
Redundant import Warning
codeql.rust.elements.Item
4328d9f to
043d99c
Compare
043d99c to
97fd70e
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 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
left a comment
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.
Great change!
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.
revert
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.