-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use predicate_must_hold_modulo_regions when resolving ghost constrain…
…ts to account for references in associated types
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
prusti-tests/tests/verify_overflow/pass/ghost-constraints/associated-types-6.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |