thrust-macros: split lib.rs into context, invariant, and spec modules#101
Merged
Conversation
Pure refactor: move the existing `context` impl into `context.rs`, and the `predicate`/`requires`/`ensures`/`_requires_ensures` machinery (plus `FnItemWithSignature`, `ExpandedTokens`, and their helpers) into `spec.rs`. The crate root now holds only the proc-macro entry points (thin delegations) and the two helpers shared across modules (`FnOuterItem`, `fn_params_with_model_ty`). The shared helpers stay private: a private root item is visible to every descendant module, so no `pub(crate)` is required. No behavior change. https://claude.ai/code/session_01WB28auaD8dSQrckqBwJWBt
There was a problem hiding this comment.
Pull request overview
This PR refactors the thrust-macros proc-macro crate by splitting the previously monolithic src/lib.rs into focused modules (context, fn_outer_item, and spec), leaving the crate root primarily as proc-macro entry points plus a small shared helper.
Changes:
- Moved
#[thrust_macros::context]expansion logic intosrc/context.rs. - Extracted the “outer impl/trait header carrier” type into
src/fn_outer_item.rs. - Moved
requires/ensures/predicate+_requires_ensuresexpansion logic intosrc/spec.rs, and updatedlib.rsto delegate to it.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| thrust-macros/src/lib.rs | Simplifies the proc-macro crate root to module wiring + proc-macro entry points delegating into submodules. |
| thrust-macros/src/spec.rs | Hosts the requires/ensures/predicate and _requires_ensures expansion implementation previously in lib.rs. |
| thrust-macros/src/context.rs | Hosts the #[thrust_macros::context] expansion implementation previously in lib.rs. |
| thrust-macros/src/fn_outer_item.rs | Defines FnOuterItem used to carry impl/trait headers for _outer_context handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coord-e
pushed a commit
that referenced
this pull request
Jun 4, 2026
Resolution of the rebase onto latest main: main (#101) extracted FnOuterItem into its own fn_outer_item module and dropped it from the crate root. Adapt the loop-invariant work accordingly — reference crate::fn_outer_item::FnOuterItem and keep the shared helpers (extract_outer_context, has_fn_bound, model_predicates, model_where_predicates, tokens_contain_ident) in the crate root.
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.
separated from #99; splits thrust-macros/src/lib.rs