Skip to content

Commit 2cc4656

Browse files
author
Remi Delmas
committed
Rename typed_swap to typed_swap_nonoverlapping.
Propagated from rust-lang/rust#134757.
1 parent 99c3f62 commit 2cc4656

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

docs/src/rust-feature-support/intrinsics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ truncf64 | Yes | |
220220
try | No | [#267](https://github.com/model-checking/kani/issues/267) |
221221
type_id | Yes | |
222222
type_name | Yes | |
223-
typed_swap | Yes | |
223+
typed_swap_nonoverlapping | Yes | |
224224
unaligned_volatile_load | No | See [Notes - Concurrency](#concurrency) |
225225
unaligned_volatile_store | No | See [Notes - Concurrency](#concurrency) |
226226
unchecked_add | Yes | |

kani-compiler/src/codegen_cprover_gotoc/codegen/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ impl GotocCtx<'_> {
18641864
}
18651865

18661866
/// Swaps the memory contents pointed to by arguments `x` and `y`, respectively, which is
1867-
/// required for the `typed_swap` intrinsic.
1867+
/// required for the `typed_swap_nonoverlapping` intrinsic.
18681868
///
18691869
/// The standard library API requires that `x` and `y` are readable and writable as their
18701870
/// (common) type (which auto-generated checks for dereferencing will take care of), and the

kani-compiler/src/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl Intrinsic {
389389
assert_sig_matches!(sig, => RigidTy::Ref(_, _, Mutability::Not));
390390
Self::TypeName
391391
}
392-
"typed_swap" => {
392+
"typed_swap_nonoverlapping" => {
393393
assert_sig_matches!(sig, RigidTy::RawPtr(_, Mutability::Mut), RigidTy::RawPtr(_, Mutability::Mut) => RigidTy::Tuple(_));
394394
Self::TypedSwap
395395
}

tests/expected/uninit/intrinsics/expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ std::ptr::write::<std::mem::MaybeUninit<u8>>.assertion.1\
66
- Status: FAILURE\
77
- Description: "Interaction between raw pointers and unions is not yet supported."\
88

9-
check_typed_swap.assertion.1\
9+
check_typed_swap_nonoverlapping.assertion.1\
1010
- Status: FAILURE\
1111
- Description: "Undefined Behavior: Reading from an uninitialized pointer of type `*mut u8`"
1212

13-
check_typed_swap.assertion.2\
13+
check_typed_swap_nonoverlapping.assertion.2\
1414
- Status: FAILURE\
1515
- Description: "Undefined Behavior: Reading from an uninitialized pointer of type `*mut u8`"
1616

@@ -35,8 +35,8 @@ std::ptr::read::<u8>.assertion.2\
3535
- Description: "Undefined Behavior: Reading from an uninitialized pointer of type `u8`"
3636

3737
Summary:
38-
Verification failed for - check_typed_swap_safe
39-
Verification failed for - check_typed_swap
38+
Verification failed for - check_typed_swap_nonoverlapping_safe
39+
Verification failed for - check_typed_swap_nonoverlapping
4040
Verification failed for - check_volatile_load
4141
Verification failed for - check_compare_bytes
4242
Verification failed for - check_copy_read

tests/expected/uninit/intrinsics/intrinsics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,23 @@ fn check_volatile_store_and_load_safe() {
131131
}
132132

133133
#[kani::proof]
134-
fn check_typed_swap() {
134+
fn check_typed_swap_nonoverlapping() {
135135
unsafe {
136136
let layout = Layout::from_size_align(16, 8).unwrap();
137137
let left: *mut u8 = alloc(layout);
138138
let right: *mut u8 = alloc(layout);
139139
// ~ERROR: Accessing `left` and `right` here, both of which are uninitialized.
140-
typed_swap(left, right);
140+
typed_swap_nonoverlapping(left, right);
141141
}
142142
}
143143

144144
#[kani::proof]
145-
fn check_typed_swap_safe() {
145+
fn check_typed_swap_nonoverlapping_safe() {
146146
unsafe {
147147
let layout = Layout::from_size_align(16, 8).unwrap();
148148
let left: *mut u8 = alloc_zeroed(layout);
149149
let right: *mut u8 = alloc_zeroed(layout);
150150
// Both `left` and `right` are initialized here.
151-
typed_swap(left, right);
151+
typed_swap_nonoverlapping(left, right);
152152
}
153153
}

tests/kani/Intrinsics/typed_swap.rs renamed to tests/kani/Intrinsics/typed_swap_nonoverlapping.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4-
// Check that `typed_swap` yields the expected results.
5-
// https://doc.rust-lang.org/nightly/std/intrinsics/fn.typed_swap.html
4+
// Check that `typed_swap_nonoverlapping` yields the expected results.
5+
// https://doc.rust-lang.org/nightly/std/intrinsics/fn.typed_swap_nonoverlapping.html
66

77
#![feature(core_intrinsics)]
88
#![allow(internal_features)]
99

1010
#[kani::proof]
11-
fn test_typed_swap_u32() {
11+
fn test_typed_swap_nonoverlapping_u32() {
1212
let mut a: u32 = kani::any();
1313
let a_before = a;
1414
let mut b: u32 = kani::any();
1515
let b_before = b;
1616
unsafe {
17-
std::intrinsics::typed_swap(&mut a, &mut b);
17+
std::intrinsics::typed_swap_nonoverlapping(&mut a, &mut b);
1818
}
1919
assert!(b == a_before);
2020
assert!(a == b_before);

0 commit comments

Comments
 (0)