Skip to content

Commit 521394a

Browse files
authored
Merge branch 'main' into sift_up
2 parents eed4094 + 38d490c commit 521394a

File tree

8 files changed

+31
-1
lines changed

8 files changed

+31
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ See [the Rust repository](https://github.com/rust-lang/rust) for details.
4747

4848
## Introducing a New Tool
4949

50-
Please use the [template available in this repository](.github/TOOL_REQUEST_TEMPLATE.md) to introduce a new verification tool.
50+
Please use the [template available in this repository](./doc/src/tool_template.md) to introduce a new verification tool.

library/alloc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ edition = "2021"
1212
core = { path = "../core" }
1313
safety = { path = "../contracts/safety" }
1414
compiler_builtins = { version = "0.1.123", features = ['rustc-dep-of-std'] }
15+
safety = { path = "../contracts/safety" }
1516

1617
[dev-dependencies]
1718
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
//
9292
// Library features:
9393
// tidy-alphabetical-start
94+
#![cfg_attr(kani, feature(kani))]
9495
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
9596
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
9697
#![feature(alloc_layout_extra)]

library/core/src/num/int_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@ macro_rules! int_impl {
21912191
without modifying the original"]
21922192
#[inline(always)]
21932193
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2194+
#[ensures(|result| *result == self >> (rhs & (Self::BITS - 1)))]
21942195
pub const fn wrapping_shr(self, rhs: u32) -> Self {
21952196
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21962197
// out of bounds

library/core/src/num/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,4 +1943,28 @@ mod verify {
19431943
generate_wrapping_shift_harness!(u64, wrapping_shl, checked_wrapping_shl_u64);
19441944
generate_wrapping_shift_harness!(u128, wrapping_shl, checked_wrapping_shl_u128);
19451945
generate_wrapping_shift_harness!(usize, wrapping_shl, checked_wrapping_shl_usize);
1946+
1947+
// `wrapping_shr` proofs
1948+
//
1949+
// Target types:
1950+
// i{8,16,32,64,128,size} and u{8,16,32,64,128,size} -- 12 types in total
1951+
//
1952+
// Target contracts:
1953+
// #[ensures(|result| *result == self >> (rhs & (Self::BITS - 1)))]
1954+
// Target function:
1955+
// pub const fn wrapping_shr(self, rhs: u32) -> Self {
1956+
//
1957+
// This function performs an panic-free bitwise right shift operation.
1958+
generate_wrapping_shift_harness!(i8, wrapping_shr, checked_wrapping_shr_i8);
1959+
generate_wrapping_shift_harness!(i16, wrapping_shr, checked_wrapping_shr_i16);
1960+
generate_wrapping_shift_harness!(i32, wrapping_shr, checked_wrapping_shr_i32);
1961+
generate_wrapping_shift_harness!(i64, wrapping_shr, checked_wrapping_shr_i64);
1962+
generate_wrapping_shift_harness!(i128, wrapping_shr, checked_wrapping_shr_i128);
1963+
generate_wrapping_shift_harness!(isize, wrapping_shr, checked_wrapping_shr_isize);
1964+
generate_wrapping_shift_harness!(u8, wrapping_shr, checked_wrapping_shr_u8);
1965+
generate_wrapping_shift_harness!(u16, wrapping_shr, checked_wrapping_shr_u16);
1966+
generate_wrapping_shift_harness!(u32, wrapping_shr, checked_wrapping_shr_u32);
1967+
generate_wrapping_shift_harness!(u64, wrapping_shr, checked_wrapping_shr_u64);
1968+
generate_wrapping_shift_harness!(u128, wrapping_shr, checked_wrapping_shr_u128);
1969+
generate_wrapping_shift_harness!(usize, wrapping_shr, checked_wrapping_shr_usize);
19461970
}

library/core/src/num/uint_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,7 @@ macro_rules! uint_impl {
21722172
without modifying the original"]
21732173
#[inline(always)]
21742174
#[rustc_allow_const_fn_unstable(unchecked_shifts)]
2175+
#[ensures(|result| *result == self >> (rhs & (Self::BITS - 1)))]
21752176
pub const fn wrapping_shr(self, rhs: u32) -> Self {
21762177
// SAFETY: the masking by the bitsize of the type ensures that we do not shift
21772178
// out of bounds

library/std/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ hashbrown = { version = "0.14", default-features = false, features = [
2626
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = [
2727
'rustc-dep-of-std',
2828
] }
29+
safety = { path = "../contracts/safety" }
2930

3031
# Dependencies of the `backtrace` crate
3132
rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] }

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
#![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
270270
#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
271271
#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
272+
#![cfg_attr(kani, feature(kani))]
272273
//
273274
// Language features:
274275
// tidy-alphabetical-start

0 commit comments

Comments
 (0)