2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2019-07-26 21:54:25 +00:00
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(dead_code)]
|
2013-02-20 00:12:12 +00:00
|
|
|
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
|
|
|
|
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2013-05-25 02:35:29 +00:00
|
|
|
use std::ptr;
|
2013-05-06 04:42:54 +00:00
|
|
|
|
2013-02-20 00:12:12 +00:00
|
|
|
pub fn main() {
|
|
|
|
let mut test = TestDescAndFn {
|
|
|
|
desc: TestDesc {
|
2014-11-06 08:05:53 +00:00
|
|
|
name: TestName::DynTestName("test".to_string()),
|
2013-02-20 00:12:12 +00:00
|
|
|
should_fail: false
|
|
|
|
},
|
2014-11-26 13:12:18 +00:00
|
|
|
testfn: TestFn::DynTestFn(22),
|
2013-02-20 00:12:12 +00:00
|
|
|
};
|
|
|
|
do_swap(&mut test);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn do_swap(test: &mut TestDescAndFn) {
|
2013-05-06 04:42:54 +00:00
|
|
|
unsafe {
|
2014-02-14 23:42:01 +00:00
|
|
|
ptr::swap(test, test);
|
2013-05-06 04:42:54 +00:00
|
|
|
}
|
2013-02-20 00:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub enum TestName {
|
2014-05-22 23:57:53 +00:00
|
|
|
DynTestName(String)
|
2013-02-20 00:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub enum TestFn {
|
2015-03-26 00:06:52 +00:00
|
|
|
DynTestFn(isize),
|
|
|
|
DynBenchFn(isize),
|
2013-02-20 00:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct TestDesc {
|
|
|
|
name: TestName,
|
|
|
|
should_fail: bool
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct TestDescAndFn {
|
|
|
|
desc: TestDesc,
|
|
|
|
testfn: TestFn,
|
|
|
|
}
|