-
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.
- Loading branch information
Showing
2 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
20 changes: 8 additions & 12 deletions
20
prusti-tests/tests/verify/fail/incorrect/old_in_pure_postcondition.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
22 changes: 22 additions & 0 deletions
22
prusti-tests/tests/verify/fail/incorrect/old_in_pure_postcondition_extern.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,22 @@ | ||
use prusti_contracts::*; | ||
|
||
#[extern_spec] | ||
impl<T> std::option::Option<T> { | ||
#[pure] // <=== Error triggered by this | ||
#[requires(self.is_some())] | ||
#[ensures(old(self) === Some(result))] | ||
pub fn unwrap(self) -> T; //~ ERROR old expressions should not appear in the postconditions of pure functions | ||
|
||
#[pure] | ||
#[ensures(result == matches!(self, Some(_)))] | ||
pub const fn is_some(&self) -> bool; | ||
} | ||
|
||
#[pure] | ||
#[requires(x.is_some())] | ||
fn test(x: Option<i32>) -> i32 { | ||
// Following error is due to stub encoding of invalid external spec for function `unwrap()` | ||
x.unwrap() //~ ERROR precondition of pure function call might not hold | ||
} | ||
|
||
fn main() { } |