Enable to parse enum constructors in annotations#14
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for parsing enum constructors in annotations, enabling the use of datatype constructors like X::A(1) in Thrust's #[thrust::requires(...)] and similar annotations. The implementation is explicitly ad-hoc and limited in scope, with plans for a more comprehensive re-implementation using macros.
Key Changes:
- Added
AnnotPathandAnnotPathSegmentstructs to represent paths in annotations - Implemented path parsing to handle multi-segment paths with optional generic arguments
- Extended the annotation parser to recognize and process enum/datatype constructors
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/ui/pass/annot_enum_simple.rs |
Adds a passing test case demonstrating enum constructor usage in requires/ensures annotations |
tests/ui/fail/annot_enum_simple.rs |
Adds a failing test case to verify that incorrect enum constructor constraints are properly detected |
src/annot.rs |
Implements core parsing logic for paths and datatype constructors, including new structs AnnotPath and AnnotPathSegment, and new parsing methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e667734 to
d669cfc
Compare
coeff-aij
pushed a commit
to coeff-aij/thrust
that referenced
this pull request
Jan 12, 2026
Enable to parse enum constructors in annotations
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.
supports only simple cases in ad-hoc way.
I plan to re-implement annotations by lifting annotation expressions into Rust functions using macros. This will allow rustc to parse them into HIR, effectively delegating path resolution to the compiler.