rust/tests/ui/swap-overlapping.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
759 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
// pretty-expanded FIXME #23616
use std::ptr;
2013-05-06 04:42:54 +00:00
pub fn main() {
let mut test = TestDescAndFn {
desc: TestDesc {
name: TestName::DynTestName("test".to_string()),
should_fail: false
},
testfn: TestFn::DynTestFn(22),
};
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
}
}
pub enum TestName {
DynTestName(String)
}
pub enum TestFn {
DynTestFn(isize),
DynBenchFn(isize),
}
pub struct TestDesc {
name: TestName,
should_fail: bool
}
pub struct TestDescAndFn {
desc: TestDesc,
testfn: TestFn,
}