Rust: Improve and rename Adt class#21059
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
| 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
4328d9f to
043d99c
Compare
043d99c to
97fd70e
Compare
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.
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.