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

fix(hax-lib/macros): handle correctly &mut Self arguments in ensures #1267

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Jan 22, 2025

This PR fixes #1266.

Consider the following Rust:

    #[hax_lib::attributes]
    trait T {
        #[hax_lib::ensures(|_|true)]
        fn v(x: &mut Self);
    }

The ensures clause was expanded (running just expand within hax repo, on the test crate) as:

    fn ensures<Self_>(x: &Self_, (x_future): (&Self)) -> bool
    where
        Self_:,
    {
        true
    }

The issue here is that we extract the various &mut arguments before renaming Self into Self_.
This PR fixes that, now the Rust expansion is:

    fn ensures<Self_>(x: &Self_, (x_future): (&Self_)) -> bool
    where
        Self_:,
    {
        true
    }

@W95Psp W95Psp marked this pull request as ready for review January 22, 2025 08:09
Copy link
Contributor

@karthikbhargavan karthikbhargavan left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@W95Psp W95Psp added this pull request to the merge queue Jan 22, 2025
See actions/runner-images#10721.
The CI currently fails, it seems related, but it is a bit strange.
@W95Psp W95Psp removed this pull request from the merge queue due to a manual request Jan 22, 2025
@W95Psp W95Psp enabled auto-merge January 22, 2025 09:26
@W95Psp
Copy link
Collaborator Author

W95Psp commented Jan 22, 2025

GHA failed for macos-12 with a unknown error and a deprecated macos-12 error, I udpated the GHA to use macos-13

@W95Psp W95Psp added this pull request to the merge queue Jan 22, 2025
Merged via the queue into main with commit b546915 Jan 22, 2025
15 checks passed
@W95Psp W95Psp deleted the fix-mut-borrow-self-ensures-clause branch January 22, 2025 10:16
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.

Post-condition on function in impl fails if function uses &mut Self
2 participants