Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hax-lib[-macros]: cfg(hax), cfg(debug_assert) and release mode policy #639

Closed
1 of 6 tasks
W95Psp opened this issue Apr 29, 2024 · 4 comments · Fixed by #983
Closed
1 of 6 tasks

Hax-lib[-macros]: cfg(hax), cfg(debug_assert) and release mode policy #639

W95Psp opened this issue Apr 29, 2024 · 4 comments · Fixed by #983
Assignees
Labels
lib Lib-related issue (e.g. annotations lib)

Comments

@W95Psp
Copy link
Collaborator

W95Psp commented Apr 29, 2024

hax-lib and hax-lib-macros provide hax-related features that are relevant only when extracting though hax (and maybe in some scenarios in debug mode, but this is not entirely clear yet)

The constraint here is production code. When we introduce a dependency to hax-lib in production code, we want (if not cfg(hax)):

  • as few as possible dependencies (from hax-lib);
  • all macros from hax-lib should be no-ops.

Solution: add a dummy hax-lib-dummy crate that is an empty shell, providing the same interface to hax-lib, but with macros being no-ops. Then hax-lib, with a cfg, either includes the real library or the dummy one.

Actions:

  • Rename hax-lib into hax-lib-impl, move it inside a brand new hax-lib crate
  • Create a hax-lib-dummy crate
  • Make hax-lib expose either the dummy one or the lib one
  • Move all docstrings to external files so that the dummy and impl crate have the same documentation
  • Feature-gate the refinement_type macro
  • Ensure correct handling of bounded integers (Bounded integers #642)

Note: some work exists in wip-toward-639

@W95Psp W95Psp added the lib Lib-related issue (e.g. annotations lib) label Apr 29, 2024
@franziskuskiefer
Copy link
Member

Putting this into separate crates requires publishing both, hence more complexity.
How about clearly separate modules instead of different crates?

@W95Psp W95Psp mentioned this issue Apr 25, 2024
9 tasks
Copy link

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the stale label Aug 28, 2024
@W95Psp
Copy link
Collaborator Author

W95Psp commented Aug 28, 2024

Still needed

@W95Psp
Copy link
Collaborator Author

W95Psp commented Oct 9, 2024

I´'ve been looking at that the last two hours or so:

  • we need two crates for hax-lib-macros: a real one and an impl one. We can't do two modules included conditionally: macros need to live in the top level module.
  • I'm not sure yet about what to do with the refinements. In hax-lib-macros, we have refinements and ints.
    • we should have a feature refinement and a feature int
    • in the dummy crate, such macros should generate simple wrappers, or maybe type synonym
  • I use cargo-public-api to make sure hax-lib[-macros] dummy VS non-dummy expose the same API
  • I opened a draft PR there feat(hax-lib): intro. hax feature #983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib Lib-related issue (e.g. annotations lib)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants