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+
18//@ run-pass
29
310#![ allow( dead_code) ]
4- // Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
5-
611
712use std:: ptr;
813
914pub fn main ( ) {
1015 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 } ,
1517 testfn : TestFn :: DynTestFn ( 22 ) ,
1618 } ;
1719 do_swap ( & mut test) ;
@@ -24,7 +26,7 @@ fn do_swap(test: &mut TestDescAndFn) {
2426}
2527
2628pub enum TestName {
27- DynTestName ( String )
29+ DynTestName ( String ) ,
2830}
2931
3032pub enum TestFn {
@@ -34,7 +36,7 @@ pub enum TestFn {
3436
3537pub struct TestDesc {
3638 name : TestName ,
37- should_fail : bool
39+ should_fail : bool ,
3840}
3941
4042pub struct TestDescAndFn {
You can’t perform that action at this time.
0 commit comments