Skip to content

Commit

Permalink
Use predicate_must_hold_modulo_regions when resolving ghost constrain…
Browse files Browse the repository at this point in the history
…ts to account for references in associated types
  • Loading branch information
vl0w committed Apr 29, 2022
1 parent cba9710 commit f7660a3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prusti-interface/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl<'tcx> Environment<'tcx> {
);

self.tcx.infer_ctxt().enter(|infcx| {
infcx.predicate_must_hold_considering_regions(&obligation)
infcx.predicate_must_hold_modulo_regions(&obligation)
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// compile-flags: -Penable_ghost_constraints=true

use prusti_contracts::*;

trait A<'a> {
type AType;
}

trait B<'a> {
type BType;

#[ghost_constraint(Self: A<'a, AType = <Self as B<'a>>::BType> , [
ensures(*result > 0)
])]
#[trusted]
fn foo(&'a self) -> &'a i32;
}

struct S {
val: i32,
}
impl<'a> A<'a> for S {
type AType = &'a i32;
}

impl<'a> B<'a> for S {
type BType = &'a i32;

#[trusted]
fn foo(&'a self) -> &'a i32 { &self.val }
}

fn main() {
let s = S {
val: 42
};
assert!(*s.foo() > 0);
}

0 comments on commit f7660a3

Please sign in to comment.