Skip to content

Commit

Permalink
Merge pull request #1267 from cryspen/fix-mut-borrow-self-ensures-clause
Browse files Browse the repository at this point in the history
fix(hax-lib/macros): handle correctly `&mut Self` arguments in `ensures`
  • Loading branch information
W95Psp authored Jan 22, 2025
2 parents 3aad8b7 + 2585ead commit b546915
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_installs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- ubuntu-latest
- ubuntu-20.04
- macos-latest
- macos-12
- macos-13
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions hax-lib/macros/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ pub fn make_fn_decoration(
mut generics: Option<Generics>,
self_type: Option<Type>,
) -> (TokenStream, AttrPayload) {
let uid = ItemUid::fresh();
let mut_ref_inputs = unmut_references_in_inputs(&mut signature);
let self_ident: Ident = syn::parse_quote! {self_};
let error = {
let mut rewriter = RewriteSelf::new(self_ident, self_type);
Expand All @@ -230,6 +228,8 @@ pub fn make_fn_decoration(
}
rewriter.get_error()
};
let uid = ItemUid::fresh();
let mut_ref_inputs = unmut_references_in_inputs(&mut signature);
let decoration = {
let decoration_sig = {
let mut sig = signature.clone();
Expand Down
12 changes: 12 additions & 0 deletions test-harness/src/snapshots/toolchain__attributes into-fstar.snap
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ unfold instance impl: Core.Ops.Arith.t_Sub t_Int t_Int =

unfold let add x y = x + y
'''
"Attributes.Issue_1266_.fst" = '''
module Attributes.Issue_1266_
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
open Core
open FStar.Mul

class t_T (v_Self: Type0) = {
f_v_pre:v_Self -> Type0;
f_v_post:x: v_Self -> x_future: v_Self -> pred: Type0{pred ==> true};
f_v:x0: v_Self -> Prims.Pure v_Self (f_v_pre x0) (fun result -> f_v_post x0 result)
}
'''
"Attributes.Nested_refinement_elim.fst" = '''
module Attributes.Nested_refinement_elim
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15"
Expand Down
10 changes: 5 additions & 5 deletions tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,11 @@ mod requires_mut {
}
}
}

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

0 comments on commit b546915

Please sign in to comment.