Rollup merge of #86880 - m-ou-se:test-manuallydrop-clone-from, r=Mark-Simulacrum

Test ManuallyDrop::clone_from.

See #86288
This commit is contained in:
Yuki Okushi 2021-07-07 12:17:41 +09:00 committed by GitHub
commit c630b6b0fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ use core::mem::ManuallyDrop;
#[test] #[test]
fn smoke() { fn smoke() {
#[derive(Clone)]
struct TypeWithDrop; struct TypeWithDrop;
impl Drop for TypeWithDrop { impl Drop for TypeWithDrop {
fn drop(&mut self) { fn drop(&mut self) {
@ -16,4 +17,11 @@ fn smoke() {
let x: Box<ManuallyDrop<[TypeWithDrop]>> = let x: Box<ManuallyDrop<[TypeWithDrop]>> =
Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop])); Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop]));
drop(x); drop(x);
// test clone and clone_from implementations
let mut x = ManuallyDrop::new(TypeWithDrop);
let y = x.clone();
x.clone_from(&y);
drop(x);
drop(y);
} }