Closed
Description
The following code reports an error about the value being moved:
use std::marker::PhantomData;
trait Foo {}
struct Bar {}
impl Foo for Bar {}
#[derive(Copy, Clone)]
union U<T>
where T: Foo
{
value1: u32,
value2: *const (),
phantom: PhantomData<*const T>
}
fn test()
{
let a: U<Bar> = U { value1: 5 };
let b = a;
let c = a;
}
While the following code works as expected:
use std::marker::PhantomData;
trait Foo {}
struct Bar {}
impl Foo for Bar {}
union U<T>
where T: Foo
{
value1: u32,
value2: *const (),
phantom: PhantomData<*const T>
}
impl<T> Copy for U<T> where T: Foo {}
impl<T> Clone for U<T> where T: Foo
{
fn clone(&self) -> Self
{
*self
}
}
fn test()
{
let a: U<Bar> = U { value1: 5 };
let b = a;
let c = a;
}
Metadata
Metadata
Assignees
Labels
No labels