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

requires and ensure clauses on traits: add inheritance #789

Open
W95Psp opened this issue Jul 18, 2024 · 3 comments
Open

requires and ensure clauses on traits: add inheritance #789

W95Psp opened this issue Jul 18, 2024 · 3 comments
Labels
attributes engine Issue in the engine enhancement New feature or request keep-open

Comments

@W95Psp
Copy link
Collaborator

W95Psp commented Jul 18, 2024

We want the default requires and ensures on an impl to be inherited from the ones specified on the trait.

Currently we are forced to repeat them:

    #[hax_lib::attributes]
    trait Operation {
        #[requires(x.lift() <= int!(127))]
        #[ensures(|result| x.lift() * int!(2) == result.lift())]
        fn double(x: u8) -> u8;
    }

    struct ViaAdd;

    #[hax_lib::attributes]
    impl Operation for ViaAdd {
        #[requires(x.lift() <= int!(127))]
        #[ensures(|result| x.lift() * int!(2) == result.lift())]
        fn double(x: u8) -> u8 {
            x + x
        }
    }
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 Sep 17, 2024
@W95Psp W95Psp added the enhancement New feature or request label Sep 18, 2024
@W95Psp
Copy link
Collaborator Author

W95Psp commented Sep 18, 2024

That's still something we need, that's one big reason for the ergonomics being bad around traits+specs

@W95Psp
Copy link
Collaborator Author

W95Psp commented Nov 22, 2024

Another example from #1125:

trait Encode {
fn encode();
}

impl<T: Encode> Encode for Option {
fn encode() {
T::encode();
}
}
Open this code snippet in the playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attributes engine Issue in the engine enhancement New feature or request keep-open
Projects
None yet
Development

No branches or pull requests

1 participant