File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change
1
+ //! Check that `std::ptr::swap` behaves correctly when the source and destination
2
+ //! pointers refer to the same memory location, avoiding issues like overlapping `memcpy`.
3
+ //! This is a regression test for issues where `ptr::swap` might behave incorrectly
4
+ //! when `src` and `dest` are the same.
5
+ //!
6
+ //! Regression test: <https://github.com/rust-lang/rust/issues/5041>
7
+
1
8
//@ run-pass
2
9
3
10
#![ allow( dead_code) ]
4
- // Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
5
-
6
11
7
12
use std:: ptr;
8
13
9
14
pub fn main ( ) {
10
15
let mut test = TestDescAndFn {
11
- desc : TestDesc {
12
- name : TestName :: DynTestName ( "test" . to_string ( ) ) ,
13
- should_fail : false
14
- } ,
16
+ desc : TestDesc { name : TestName :: DynTestName ( "test" . to_string ( ) ) , should_fail : false } ,
15
17
testfn : TestFn :: DynTestFn ( 22 ) ,
16
18
} ;
17
19
do_swap ( & mut test) ;
@@ -24,7 +26,7 @@ fn do_swap(test: &mut TestDescAndFn) {
24
26
}
25
27
26
28
pub enum TestName {
27
- DynTestName ( String )
29
+ DynTestName ( String ) ,
28
30
}
29
31
30
32
pub enum TestFn {
@@ -34,7 +36,7 @@ pub enum TestFn {
34
36
35
37
pub struct TestDesc {
36
38
name : TestName ,
37
- should_fail : bool
39
+ should_fail : bool ,
38
40
}
39
41
40
42
pub struct TestDescAndFn {
You can’t perform that action at this time.
0 commit comments