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

Introduce hax_lib::BACKEND::replace_body attribute #1321

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Feb 20, 2025

This PR:

  • introduces a replace_body for each backend, that helps rewritting only the body of a function. That's what I use for my SIMD models, that's very handy.
  • refactor a bit the proc_macros module in hax_lib so that it's mostly generated by build.rs. This will help to maintain the library.

Example:

    #[hax_lib::fstar::replace_body("magic ${x}")]
    fn f(x: u8, y: u8) -> u8 {
        1 + 2
    }
    struct Foo;
    impl Foo {
        #[hax_lib::fstar::replace_body("(magic (${self} <: $:{Self})) ${x}")]
        fn assoc_fn(&self, x: u8) {}
    }
    impl ToString for Foo {
        #[hax_lib::fstar::replace_body(r#""The type was $:{Self}""#)]
        fn to_string(&self) -> String {
            "Hello".into()
        }
    }

@W95Psp W95Psp requested a review from a team as a code owner February 20, 2025 13:42
@W95Psp
Copy link
Collaborator Author

W95Psp commented Feb 20, 2025

@jschneider-bensch this PR might be interesting for you!

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.

1 participant