Skip to content

thrust-macros: split lib.rs into context, invariant, and spec modules#101

Merged
coord-e merged 1 commit into
mainfrom
coord-e/separate-macros-lib
Jun 3, 2026
Merged

thrust-macros: split lib.rs into context, invariant, and spec modules#101
coord-e merged 1 commit into
mainfrom
coord-e/separate-macros-lib

Conversation

@coord-e
Copy link
Copy Markdown
Owner

@coord-e coord-e commented Jun 3, 2026

separated from #99; splits thrust-macros/src/lib.rs

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
Copy link
Copy Markdown

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 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 into src/context.rs.
  • Extracted the “outer impl/trait header carrier” type into src/fn_outer_item.rs.
  • Moved requires/ensures/predicate + _requires_ensures expansion logic into src/spec.rs, and updated lib.rs to 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 coord-e merged commit 646323a into main Jun 3, 2026
7 checks passed
@coord-e coord-e deleted the coord-e/separate-macros-lib branch June 3, 2026 15:22
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.
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.

3 participants