Skip to content

Conversation

@coord-e
Copy link
Owner

@coord-e coord-e commented Dec 14, 2025

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.

@coord-e coord-e marked this pull request as draft December 14, 2025 09:40
@coord-e coord-e marked this pull request as ready for review December 29, 2025 15:17
@coord-e coord-e requested a review from Copilot December 29, 2025 15:17
Copy link

Copilot AI left a 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 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 AnnotPath and AnnotPathSegment structs 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.

@coord-e coord-e merged commit b7160f2 into main Dec 30, 2025
3 checks passed
@coord-e coord-e deleted the enum-in-annot branch December 30, 2025 05:54
coeff-aij pushed a commit to coeff-aij/thrust that referenced this pull request Jan 12, 2026
Enable to parse enum constructors in annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants