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:
commit
c630b6b0fc
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user