Skip to content

Add first proof #25

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

Open
wants to merge 38 commits into
base: add-permissions
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e351be9
Add first proof
jaisnan Jul 10, 2024
fd1c9c2
Add contracts for Layout and Alignment (#33)
tautschnig Jul 11, 2024
af85a10
Move contracts out of library for now
celinval Jul 16, 2024
eea60ef
Record library patch and delete library/
celinval Jul 16, 2024
47a29de
Delete library folder so we can recreate subtree
celinval Jul 17, 2024
bf2766f
Merge commit '0cd155fda0d5b0b3ba666cd9df978d380f6c7067' as 'library'
celinval Jul 17, 2024
0cd155f
Squashed 'library/' content from commit 88f01060642
celinval Jul 17, 2024
d11fcb2
Move contracts back to library/contracts
celinval Jul 17, 2024
a70ad70
Reapply repository changes to library files
celinval Jul 17, 2024
dd0d265
Squashed 'library/' changes from 88f01060642..a2cf63619d7
jaisnan Jul 17, 2024
723914d
Merge commit 'dd0d2657eb2c8466bbd9fa6ea4bf2b094565c680' into sync-202…
jaisnan Jul 17, 2024
b0cc943
Update toolchain to 07-17
jaisnan Jul 18, 2024
4f4d032
Add a challenge for `btree::node` module (#26)
zhassan-aws Jul 19, 2024
0be79d6
char and ascii_char contracts (#48)
carolynzech Aug 1, 2024
ec6d98e
Add scripts for local subtree update (#46)
jaisnan Aug 12, 2024
01e4da0
prevent merge conflicts
carolynzech Aug 16, 2024
9d7b420
Squashed 'library/' changes from a2cf63619d7..9cc3bc6add3
carolynzech Aug 16, 2024
f5d8b9d
Merge commit '9d7b4208352e30d0e2a3090a964ef6f711c407e9' into sync-202…
carolynzech Aug 16, 2024
9cec589
put kani imports back
carolynzech Aug 16, 2024
1761d8a
Update toolchain to 2024-08-07
carolynzech Aug 16, 2024
24a0b16
remove unstable ptr-to-ref-cast-checks and update submodules
carolynzech Aug 16, 2024
262f391
Merge branch 'main' into add-result-contract
jaisnan Aug 16, 2024
c155b26
Contracts and harnesses for `ptr::Unique` (#45)
tautschnig Aug 20, 2024
03c735b
Add harnesses for all functions in Alignment (#42)
tautschnig Aug 20, 2024
cc2c94b
Merge branch 'main' into add-result-contract
tautschnig Aug 20, 2024
5595535
Challenge proposal: SmallSort (#57)
qinheping Aug 20, 2024
62e241a
Add MD extension to SmallSort challenge (#60)
carolynzech Aug 20, 2024
359fe20
Add challenge on memory safety of String (#55)
zhassan-aws Aug 20, 2024
8f3252f
Add self to pull_requests.toml (#65)
patricklam Aug 22, 2024
46352cf
Introduce tool template (#64)
rahulku Aug 22, 2024
b3fb221
Fix challenge number (#63)
zhassan-aws Aug 22, 2024
957d2bb
Add "ranjitjhala" and "carolynzech" to commitee (#68)
jaisnan Aug 22, 2024
962b36b
Challenge proposal: NonNull (#52)
tautschnig Aug 26, 2024
e0d6676
Challenge Proposal: `core::time::Duration` (#73)
feliperodri Aug 27, 2024
b588f71
`NonZero` Challenge (#70)
carolynzech Aug 27, 2024
c191318
Simplify pr workflow to require 2 approvals on all PR's (#74)
jaisnan Aug 27, 2024
1f0fc95
Challenge Proposal: Floats/Ints (#58)
carolynzech Aug 27, 2024
4b36a0e
Merge branch 'main' into add-result-contract
jaisnan Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,14 @@

#![stable(feature = "rust1", since = "1.0.0")]

use safety::requires;
use crate::iter::{self, FusedIterator, TrustedLen};
use crate::ops::{self, ControlFlow, Deref, DerefMut};
use crate::{convert, fmt, hint};

#[cfg(kani)]
use crate::kani;

/// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).
///
/// See the [module documentation](self) for details.
Expand Down Expand Up @@ -1459,6 +1463,7 @@ impl<T, E> Result<T, E> {
#[inline]
#[track_caller]
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
#[requires(self.is_ok())]
pub unsafe fn unwrap_unchecked(self) -> T {
debug_assert!(self.is_ok());
match self {
Expand Down Expand Up @@ -1491,6 +1496,7 @@ impl<T, E> Result<T, E> {
#[inline]
#[track_caller]
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
#[requires(self.is_err())]
pub unsafe fn unwrap_err_unchecked(self) -> E {
debug_assert!(self.is_err());
match self {
Expand Down Expand Up @@ -1982,3 +1988,17 @@ impl<T, E, F: From<E>> ops::FromResidual<ops::Yeet<E>> for Result<T, F> {
impl<T, E> ops::Residual<T> for Result<convert::Infallible, E> {
type TryType = Result<T, E>;
}

#[cfg(kani)]
#[unstable(feature="kani", issue="none")]
mod verify {
use super::*;

#[kani::proof_for_contract(Result::unwrap_unchecked)]
pub fn check_unwrap_unchecked() {
let val: Result<u32, u64> = kani::any();
let ok_variant: Result<u32, u64> = Ok(0);
let copy = unsafe { ok_variant.unwrap_unchecked() };
assert_eq!(val, Result::Ok(copy));
}
}
Loading