Skip to content

Introduce hax_lib::BACKEND::replace_body attribute#1321

Merged
W95Psp merged 6 commits intomainfrom
replace-body
Mar 6, 2025
Merged

Introduce hax_lib::BACKEND::replace_body attribute#1321
W95Psp merged 6 commits intomainfrom
replace-body

Conversation

@W95Psp
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor Author

W95Psp commented Feb 20, 2025

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

Copy link
Copy Markdown
Contributor

@maximebuyse maximebuyse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems useful!

@W95Psp W95Psp enabled auto-merge March 6, 2025 10:49
@W95Psp W95Psp added this pull request to the merge queue Mar 6, 2025
Merged via the queue into main with commit 82eb8fa Mar 6, 2025
15 checks passed
@W95Psp W95Psp deleted the replace-body branch March 6, 2025 11:24
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