Closed
Description
Take this struct for instance:
#[pin_project]
#[derive(Debug)]
pub struct Socket {
#[cfg_attr(unix, pin)]
#[cfg(unix)]
inner: tokio::net::unix::UnixStream,
#[cfg_attr(windows, pin)]
#[cfg(windows)]
inner: tokio_named_pipes::NamedPipe,
}
I get the error
error[E0124]: field `inner` is already declared
--> src/io/socket.rs:29:5
|
26 | inner: tokio::net::unix::UnixStream,
| ----------------------------------- `inner` first declared here
...
29 | inner: tokio_named_pipes::NamedPipe,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field already declared
Even though, as far as I can tell, this should work. My guess here is that pin-project
is run before the #[cfg()]
s are evaluated, and ends up not propagating them, but I'm not sure?